SlickGrid
SlickGrid copied to clipboard
Cannot de-select rows when clicking in last selected cell
When using RowSelectionModel to enable multiple row selection in a grid, clicking the last selected cell without holding down the shift/ctrl/alt/meta keys will not de-select other selected rows. Issue may be related to there being no change in the active cell.
The behavior can be reproduced in this example: http://mleibman.github.com/SlickGrid/examples/example9-row-reordering.html
Can't repro.
I was able to reproduce again with Chrome and Firefox in Windows 7 and Chrome on Mac. Did you make sure to click in the same cell that you clicked in to select the row in the first place? I found that clicking in another cell in the same row will properly deselect all other rows.
Ah, got it. Thanks.
In the meantime I got the desired UX this way... In case anyone needs it.
var lastRowSelected = '';
var clearRowSelection = function () {
grid.resetActiveCell();
grid.getSelectionModel().setSelectedRows([]);
lastRowSelected = '';
};
grid.setSelectionModel(new Slick.RowSelectionModel());
grid.onSelectedRowsChanged.subscribe(function () {
var selectionIndex = grid.getSelectedRows()[0];
if (prevGridSelection !== selectionIndex) {
//logic
prevGridSelection = selectionIndex;
} else {
clearRowSelection();
}
});
grid.onClick.subscribe(function (e, args) {
if (lastRowSelected === args.row) {
grid.resetActiveCell();
}
});
this is pretty nasty, it seems there's no way to clear the selection using ctrl-click
fixed in https://github.com/6pac/SlickGrid
Thanks, that works. I also noticed another issue, if one row is selected, I can't de-select it using ctrl-click, so it's not possible to deselect all the rows as I would expect using ctrl-click. Can you please fix that too?
just committed a fix for this.
thanks for persisting, i uncovered what was clearly a bug in slick.rowselectionmodel.js.
i've also added a new test file tests/test-4-rows-paging.html, which is the one i've been using to debug this.