2014-09-01 61 views
0

我一直在为sencha论坛以及堆栈溢出寻找解决方案。我无法得到这个问题的适当解决方案。我想在该行的检查列的checkchange事件中编辑网格中某行的特定单元格。在checkcheumn的checkchange事件上进行单元格编辑

以下是代码 -

  var unitStore = Ext.create('Ext.data.Store', { 
          fields: ['phone'], 
          autoLoad:true , 
          proxy: { 
    type: 'memory', 

} 
         }); 

     var abc=Ext.create('Ext.data.Store', { 
storeId:'simpsonsStore', 
fields:['name', 'email', 'phone'], 
data:{'items':[ 
    { 'name': 'Lisa', "email":"[email protected]", "phone":"555-111-1224" }, 
    { 'name': 'Bart', "email":"[email protected]", "phone":"555-222-1234" }, 
    { 'name': 'Homer', "email":"[email protected]", "phone":"555-222-1244" }, 
    { 'name': 'Marge', "email":"[email protected]", "phone":"555-222-1254" } 
]}, 
proxy: { 
    type: 'memory', 
    reader: { 
     type: 'json', 
     root: 'items' 
    } 
} 
    }); 
    var cellEditing=Ext.create('Ext.grid.plugin.CellEditing', { 
     clicksToEdit: 1, 
    }); 
     Ext.create('Ext.grid.Panel', { 
title: 'Simpsons', 
plugins: [cellEditing], 
store: abc, 
columns: [ 
{xtype:'checkcolumn' ,id:'check',dataIndex:'check', text:'Select' ,listeners:{ 
     checkchange:function(checkbox, rowIndex, checked, eOpts){ 
       if(checked==true){ 
        //var abc=checkbox.up('grid').getStore().getAt(rowIndex).get('name'); 
        var x=[{'phone':'2'},{'phone':'3'}]; 
        unitStore.loadData(x); 
        //cellEditing.startEditByPosition({row: rowIndex, column: 3}); 


       // this.up('grid').getSelectionModel().setCurrentPosition({row:   rowIndex, column: 3}); 
        cellEditing.startEdit(rowIndex,3); 

       } 


     } 
    }}, 
    { text: 'Name', dataIndex: 'name' }, 
    { text: 'Email', dataIndex: 'email', flex: 1 }, 
    { text: 'Phone', dataIndex: 'phone',editor:{xtype:'combo',store:unitStore, 
    queryMode:'local',displayField: 'phone', 
valueField: 'phone',selectOnFocus:true,triggerAction: 'all', 
    } }, 

], 
height: 200, 
width: 400, 
renderTo: Ext.getBody() 
    }); 
+0

有一个格式化SO上的问题的教程。请参考。它可以帮助你很多。 – 2014-09-01 07:45:26

+0

感谢您的建议。对于我来说,我很新。在发布任何进一步信息之前,请继续阅读。 :) – 2014-09-01 07:52:20

回答

1

使用Ext.defer调用startEdit中功能之前延迟。在这个小提琴中修改你的样本:https://fiddle.sencha.com/#fiddle/9lm

+0

非常感谢:) – 2014-09-01 10:04:14

+0

我在Ext JS中使用单元格编辑网格。我想通过手动调用startEdit方法而不是点击来编辑单元格。如何禁止编辑器通过点击进行编辑。我有一个只允许编辑特定列的检查栏。 – 2014-09-01 10:11:03

+0

我修改了celleditor插件的beforeedit监听器。它的工作。 – 2014-09-01 10:32:20

相关问题