I want to select multiple rows by using grid.getSelectionModel().select(Indexes) in extjs 4.1 Anyone knows how to do it?? Here is my code:
var grid = Ext.getCmp('GridStudents');
var fieldvalues = '2054,2055,2057';
var arr = fieldvalues.split(',');
for (var j = 0; j < arr.length; j++)
{
index = grid.store.find('StudentID', arr[j]);
grid.getSelectionModel().select(j);
}
First of all your selection model must have mode
MULTI
orSIMPLE
.Then you can use method
selectRange(startRow, endRow)
when you want to select bunch of records which are in one block.You can also use select and pass array of records or select one by one using index.
Both this function accepts another parameter
keepExisting
. When set to true, existing selection is kept (as name suggests).Also you pass
j
toselect
method instead ofindex
.So easiest fix would be:
If your model is configured for multiple selection, it should work.
Fiddle: http://jsfiddle.net/7ofLb3Ls/3/
As an alternative you can try this code:
Fiddle: http://jsfiddle.net/7ofLb3Ls/4/