ui-grid icon indicating copy to clipboard operation
ui-grid copied to clipboard

Selected row(s) loses "selected" class on grid redraw

Open c0bra opened this issue 13 years ago • 8 comments

As demonstrated in this plunk: http://run.plnkr.co/plunks/Nsy6iz/

Resizing the browser, opening the console, etc., causes selected rows to lose their "selected" class.

c0bra avatar Apr 03 '13 20:04 c0bra

This happens on all of the demos actually. http://angular-ui.github.com/ng-grid/

specialjyo avatar Apr 03 '13 23:04 specialjyo

@specialjyo True, I just wanted to provide some directions to reproduce.

c0bra avatar Apr 04 '13 14:04 c0bra

It looks like this is because in grid.setRenderedRows(), it uses row.setVars() to overwrite .selected in the renderedRows with what's in filteredRows. As near as I can tell, .selected never gets set in filteredRows, ONLY in renderedRows. So when you redraw the grid, you lose your selection.

c0bra avatar Apr 08 '13 17:04 c0bra

in order to maintain selections you need to use a primayKey please see: https://github.com/angular-ui/ng-grid/issues/233

orneryd avatar Apr 08 '13 19:04 orneryd

Like so? http://plnkr.co/edit/FYfkY8

It doesn't seem to work with the current ng-grid.debug.js

Edit: Actually plunker is being really wonky. I will try to get a jsfiddle set up.

c0bra avatar Apr 08 '13 19:04 c0bra

I updated from ng-grid 2.0.2 to 2.0.3 and i'm having the same problem.

Fantastic, Tim. Thank you!

c0bra avatar Apr 09 '13 21:04 c0bra

This issues is still in the last version

mariannegru avatar May 13 '13 15:05 mariannegru