我一直在爲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()
});
有一個格式化SO上的問題的教程。請參考。它可以幫助你很多。 – 2014-09-01 07:45:26
感謝您的建議。對於我來說,我很新。在發佈任何進一步信息之前,請繼續閱讀。 :) – 2014-09-01 07:52:20