2014-09-01 20 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

相關問題