SlickGrid icon indicating copy to clipboard operation
SlickGrid copied to clipboard

Cannot de-select rows when clicking in last selected cell

Open abielr opened this issue 13 years ago • 8 comments

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

abielr avatar Apr 13 '12 19:04 abielr

Can't repro.

mleibman avatar Apr 13 '12 23:04 mleibman

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.

abielr avatar Apr 13 '12 23:04 abielr

Ah, got it. Thanks.

mleibman avatar Apr 14 '12 00:04 mleibman

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();
                    }
            });

coryasilva avatar Jun 01 '13 01:06 coryasilva

this is pretty nasty, it seems there's no way to clear the selection using ctrl-click

sswam avatar Aug 09 '16 00:08 sswam

fixed in https://github.com/6pac/SlickGrid

6pac avatar Aug 19 '16 12:08 6pac

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?

sswam avatar Aug 22 '16 02:08 sswam

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.

6pac avatar Aug 22 '16 05:08 6pac