PDA

View Full Version : GridPanel, try to 'multiselect' rows by code, but only the last is selected



loginfabio
20 Feb 2013, 2:41 AM
Hello,

I have a gridpanel in a form with a CheckboxModel, when I load the store, I have a callback that find the requested records and selects the rows, but I found that only the last record is selected.
I try adding 'multiSelect: true, simpleSelect: true' in the grid configuration, but result doesn't change.

Here's some code

GRIDPANEL view:


Ext.define('Smqs.view.knowledgebase.KlbGroupGrid', {
extend: 'Ext.grid.Panel',
requires: ['Ext.selection.CheckboxModel'],
alias: 'widget.smqs-klbgroupgrid',id:'klbgroupgrid',
height: 154,
multiSelect: true, simpleSelect: true,
store:'Groups',
viewConfig:{enableRowBody:true},
initComponent: function(){
var me = this,
aColumns = [
{text: 'NAME', width:'95%', dataIndex:'GRNO'}
],
sm = Ext.create('Ext.selection.CheckboxModel', {mode : 'MULTI'});
Ext.apply(this,{selModel: sm, columns: aColumns});
this.callParent();
}
});


WINDOW controller (init - show)


Ext.getStore('Groups').load({
callback: function (records, operation, success) {
var vire = val.down('form').down('#klbgroupgrid').getView();
vire.select(0);
vire.select(1);
vire.select(2);
//for (var i=0;i<nure;i++) {
// var rowIndex = this.find('GRID', parseInt(arre[i]));
// if (rowIndex>=0) {
// vire.select(rowIndex);
// }
//}
}
});


I've commented the loop and forced to select the first three rows and
only the 3rd row results selected.

Thanks in advance

loginfabio
20 Feb 2013, 3:02 AM
Sorry...

I haven't read documentation completely, I've changed code to:


Ext.getStore('Groups').load({
callback: function (records, operation, success) {
var vire = val.down('form').down('#klbgroupgrid').getSelectionModel();
vire.select(0,true);
vire.select(1,true);
vire.select(2,true);
//for (var i=0;i<nure;i++) {
// var rowIndex = this.find('GRID', parseInt(arre[i]));
// if (rowIndex>=0) {
// vire.select(rowIndex);
// }
//}
}
});


and it works.