我一直在寻找在sencha论坛以及堆栈溢出的解决方案。我无法得到这个问题的正确解决方案。我想在该行中检查列的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":"lisa@simpsons.com", "phone":"555-111-1224" },
{ 'name': 'Bart', "email":"bart@simpsons.com", "phone":"555-222-1234" },
{ 'name': 'Homer', "email":"home@simpsons.com", "phone":"555-222-1244" },
{ 'name': 'Marge', "email":"marge@simpsons.com", "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 :(得分:1)
在调用startEdit函数之前使用Ext.defer延迟。在这个小提琴中修改了你的样本:https://fiddle.sencha.com/#fiddle/9lm