extjs4.1 - How to select multiple rows by using grid.getSelectionModel().select(Indexes) in extjs 4.1 -


i want select multiple rows using grid.getselectionmodel().select(indexes) in extjs 4.1 knows how it?? here code:

var grid = ext.getcmp('gridstudents'); var fieldvalues = '2054,2055,2057'; var arr = fieldvalues.split(',');  (var j = 0; j < arr.length; j++)  {   index = grid.store.find('studentid', arr[j]);   grid.getselectionmodel().select(j); } 

first of selection model must have mode multi or simple.

then can use method selectrange(startrow, endrow) when want select bunch of records in 1 block.

you can use select , pass array of records or select 1 one using index.

both function accepts parameter keepexisting. when set true, existing selection kept (as name suggests).

also pass j select method instead of index.

so easiest fix be:

for (var j = 0; j < arr.length; j++)  {     var index = grid.store.find('studentid', arr[j]);     grid.getselectionmodel().select(index, true); } 

if model configured multiple selection, should work.

fiddle: http://jsfiddle.net/7oflb3ls/3/

as alternative can try code:

var grid = sender.up('grid'); var fieldvalues = '2054,2055,2057'; var arr = fieldvalues.split(','); var records = ext.array.filter(     grid.store.data.items,     function(r) {         return arr.indexof(''+r.get('studentid')) !== -1;      }  );  grid.getselectionmodel().select(records); 

fiddle: http://jsfiddle.net/7oflb3ls/4/


Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -