ExtJs checkboxselectionmodel
我使用带有复选框SelectionModel的GridPanel进行项目选择。 在编辑模式中,一些选项已经被选中,我试图在加载表单时预先选择行ExtJs checkboxselectionmodel,extjs,Extjs,我使用带有复选框SelectionModel的GridPanel进行项目选择。 在编辑模式中,一些选项已经被选中,我试图在加载表单时预先选择行 ... store.load(); //curSelections is an array containing the some ForeingKey IDs of the selected records. ... for (var i = 0; i < curSelections.length; i++) { console.log
...
store.load();
//curSelections is an array containing the some ForeingKey IDs of the selected records.
...
for (var i = 0; i < curSelections.length; i++) {
console.log('found personel ' + curSelections[i] + ' at ',
store.findExact('Id', curSelections[i]));
selectedRecords.push(store.findExact('Id', curSelections[i]));
}
//everything is fine according to console log.
checkGrid.getSelectionModel().selectRecords(selectedRecords, true);
formWin.show();
一些网格代码
var sm = new Ext.grid.CheckboxSelectionModel({
singleSelect: false,
sortable: false,
checkOnly: true
});
checkGrid = new Ext.grid.GridPanel({
xtype: 'grid',
store: obPersonelStore,
loadMask: true,
layout: 'fit',
height: 120,
id: 'grdIsBirimiPersonelListesi',
columns: [
sm,
{
我错过了一些简单的东西,但不知道是什么。
非常感谢您的任何帮助。我不能100%确定您想要实现什么。你说: 我找到整个列表中的选定行 您的意思是要选择每一行吗?在这种情况下,您可以使用CheckboxSelectionModel的
selectAll()
方法
如果您只想选择一些行,那么首先我需要查看用于获取这些行的代码,但可能是您想使用selectRecords()
而不是selectRows()
返回一个数字索引。选择模型。需要一个记录对象数组。你试过了吗?要么那样,要么使用商店。要按索引检索记录以传递给selectRecords()。请尝试:
var store = new Ext.data.Store({
...
});
var grid = new Ext.grid.GridPanel({
store: store,
...
});
store.on('load', function() {
grid.getSelectionModel().selectFirstRow();
});
store.load();
这是一个打字错误,我在原来的帖子中添加了更多的代码。我不会添加整个代码,因为它没有多大意义。好吧,出于某种原因,我认为selectRecords需要行索引。现在有趣的是,它工作了,它们被选中了,但是当加载窗格(旋转图像)消失时,选择被清除。您可以尝试将选择逻辑移动到store.load事件的处理程序中,以确保首先完成存储加载,例如,store.on('load',function(){//selection logic});非常感谢你。它解决了这个问题你帮了大忙,再次谢谢你。
var store = new Ext.data.Store({
...
});
var grid = new Ext.grid.GridPanel({
store: store,
...
});
store.on('load', function() {
grid.getSelectionModel().selectFirstRow();
});
store.load();