PDA

View Full Version : CheckboxModel Selection Model select don't render on grid



ssamuel68
21 Aug 2012, 11:25 AM
Hi, i have a problem checking multiple rows on a grid.

The selModel on my grid:


var selModel = new Ext.selection.CheckboxModel({
mode: 'MULTI'
});


Here i get the seleccion model:


var selModel = Ext.getCmp('myGrid').getSelectionModel();


Then if I use "selModel.select(2)" for example, it checks the 3rd row. All good by now.

If I pass an array, for example "selModel.select([0,2,3])" and then I call selModel.selected it returns the 3 rows selected but the checked items are not displayed in the grid.

I don't know is this is a bug or if I'm doing something wrong.

Thx.
Sam

droessner
21 Aug 2012, 1:08 PM
You can't send an array of indexes to the select function. The select function only takes a single index or an array of records. You would have to get the record at each index and then send an array of those records.

http://docs.sencha.com/ext-js/4-1/#!/api/Ext.selection.CheckboxModel-method-select

ssamuel68
21 Aug 2012, 2:10 PM
I also pass an array of the records I want to check and didnt work for me.

My solution was do selModel.selectAll() and then use selModel.deselect(here I pass the index or the record I want to deselect)

I think this is a patch but not a final solution.

Work for me.

droessner
22 Aug 2012, 4:40 AM
I just set up a quick test case and this is working for me:



var grid = Ext.getCmp('myGrid'),
store = grid.getStore(),
selModel = grid.getSelectionModel();

selModel.select([
store.getAt(0),
store.getAt(1),
store.getAt(3)
]);