Extjs 渲染后如何在Ext.selection.CheckboxModel中设置选中项?
我正在Extjs 渲染后如何在Ext.selection.CheckboxModel中设置选中项?,extjs,extjs6,checked,Extjs,Extjs6,Checked,我正在Ext.grid.Panel中使用Ext.selection.CheckboxModel,并且在数据绑定和组件重新定义后,whant检查了一些项目。部件工作正常但错误的部分如下所示: listeners: { afterRender: function (thisObj, eOpts) { var window = Ext.ComponentQuery.query('#' + 'requestOperator_kbkAccess-window
Ext.grid.Panel
中使用Ext.selection.CheckboxModel
,并且在数据绑定和组件重新定义后,whant检查了一些项目。部件工作正常但错误的部分如下所示:
listeners: {
afterRender: function (thisObj, eOpts) {
var window = Ext.ComponentQuery.query('#' + 'requestOperator_kbkAccess-window')[0];
if (window) {
var row = window.accessGrid.getSelectionModel().getSelection()[0],
ppp = row.get('Ppp'),
codes = ppp.map(a => a.Code);
Ext.defer(function () {
var selections = [];
codes.forEach(function (item, index) {
let i = thisObj.getStore().find('Code', item);
if (i !== -1) {
selections.push(store.getAt(i))
}
});
console.log(thisObj.getStore().data);
thisObj.getSelectionModel().select(selections);
}, 100);
}
}
}
此代码从父组件接收类似于02207709
的代码字符串,并尝试在Ext.selection.CheckboxModel
中设置为选中此代码。这段代码的错误工作是行let i=thisObj.getStore().find('code',item)代码>返回-1,thisObj.getStore()中调试中的项目计数。数据
为0。但在控制台中,我看到console.log(thisObj.getStore().data)代码>返回预期结果:
在viewready
上,结果相同
我是extJs新手,不明白在这个简单的功能中我做错了什么?请帮忙。谢谢。您需要在商店加载后执行此功能:()
你可以这样做:
listeners: {
afterRender: function (thisObj, eOpts) {
thisObj.getStore().on('load', function () {
var window = Ext.ComponentQuery.query('#' + 'requestOperator_kbkAccess-window')[0];
if (window) {
var row = window.accessGrid.getSelectionModel().getSelection()[0],
ppp = row.get('Ppp'),
codes = ppp.map(a => a.Code);
Ext.defer(function () {
var selections = [];
codes.forEach(function (item, index) {
let i = thisObj.getStore().find('Code', item);
if (i !== -1) {
selections.push(store.getAt(i))
}
});
console.log(thisObj.getStore().data);
thisObj.getSelectionModel().select(selections);
}, 100);
}
});
}
},
您需要在加载存储后执行此功能:()
你可以这样做:
listeners: {
afterRender: function (thisObj, eOpts) {
thisObj.getStore().on('load', function () {
var window = Ext.ComponentQuery.query('#' + 'requestOperator_kbkAccess-window')[0];
if (window) {
var row = window.accessGrid.getSelectionModel().getSelection()[0],
ppp = row.get('Ppp'),
codes = ppp.map(a => a.Code);
Ext.defer(function () {
var selections = [];
codes.forEach(function (item, index) {
let i = thisObj.getStore().find('Code', item);
if (i !== -1) {
selections.push(store.getAt(i))
}
});
console.log(thisObj.getStore().data);
thisObj.getSelectionModel().select(selections);
}, 100);
}
});
}
},