View Full Version : Grid selection model select() doesn't highlight the row?

27 Sep 2013, 10:31 AM
I'm attempting to re-select previously selected records after a grid store load. Any ideas why the following code will select the rows, but not actually highlight them visually in the grid? Is it too early in the store's event stack or something?

grid.getSelectionModel().selectAll() selects and highlights as I'd expect, but not the code below.

var selModel = grid.getSelectionModel();
var selections = selModel.getSelection();
callback: function(records, operation, success) {
if (success) {
// Highlight and select prev selected rows

30 Sep 2013, 3:48 AM
After load you have different model instances (still with same id). This may prevent view from showing correct status.

30 Sep 2013, 5:30 AM
Still not sure what the fix is. I tried replacing selModel declared before load... selModel.select(selections) with grid.getSelectionModel().select(selections) in the callback and still no highlighted rows.

30 Sep 2013, 9:41 AM
Try to create an array of new records basing on ids of old records and then pass new array to .select().

30 Sep 2013, 11:50 AM
Ok that got me thinking...

Adding the code below to the callback instead of selModel.select(selections)works:

for (var i = 0; i < selections.length; i++) {
selModel.select(selections[i].index, true, false);

I probably should still check to make sure the row actually matches the prev selection in case there are new records that throw off the index. At least I know the above code highlights the row.

1 Oct 2013, 10:12 PM
You can try store.getById(selecetions[i].getId()).