Opened 11 years ago

Closed 8 years ago

Last modified 8 years ago

#7304 closed defect (fixed)

Selection doesn't follow row when sorting in DataGrid

Reported by: Bryan Forbes Owned by:
Priority: high Milestone: 1.7
Component: DojoX Grid Version: 1.1.1
Keywords: Cc: David Schwartz
Blocked By: Blocking:

Description

When sorting a column after selecting a row, the selection should follow the item selected rather than the row index in the grid.

Attachments (1)

Selection-identity-based (5.9 KB) - added by jake richardson 10 years ago.
Prevent selection from occuring when no item is available.

Download all attachments as: .zip

Change History (27)

comment:1 Changed 11 years ago by Bryan Forbes

Milestone: tbd1.3

comment:2 Changed 11 years ago by Nathan Toone

Owner: changed from Bryan Forbes to Nathan Toone

Reassigning to me

comment:3 Changed 11 years ago by Nathan Toone

Milestone: 1.3future

comment:4 Changed 11 years ago by Becky Gibson

Cc: David Schwartz added

comment:5 Changed 10 years ago by Bertrand Fan

This bug also applies when selectionMode="multiple":

If you look at the grid Multiple in this test: http://archive.dojotoolkit.org/nightly/dojotoolkit/dojox/grid/tests/test_selection.html

then toggle a few rows and sort by column, the selected rows are now different rows (at the same positions that they were before).

comment:6 Changed 10 years ago by David Schwartz

Just to be clear, this issue exists whether the selectionMode is 'multiple', 'extended' or 'single'.

comment:7 Changed 10 years ago by xbillbill

is it a difficult bug to fix?

comment:8 Changed 10 years ago by Nathan Toone

It's moderately difficult to fix - what would need to happen is we'd need to keep track of selection on a per-item basis...rather than a per-row basis (as we currently are).

Most of the issue is making sure that we don't break other stuff in making that change. Patches are welcome - but I just don't have cycles to dedicate to solving this in the week before 1.4 gets frozen.

comment:9 Changed 10 years ago by jake richardson

The above patch might break the compat grid, due to the getFirstSelected/getNextSelected not doing anything useful anymore.

comment:10 Changed 10 years ago by jake richardson

Fails when selecting items not in the local cache...

Changed 10 years ago by jake richardson

Attachment: Selection-identity-based added

Prevent selection from occuring when no item is available.

comment:11 Changed 10 years ago by jake richardson

Above patch is still not usable due selection not working on rows that have not loaded their associated items from the store.

comment:12 Changed 10 years ago by jake richardson

Identifier based selection management will not allow for virtualized selection (select all, or selecting an item and scrolling down and shift-selecting).

Alternative solution would be to deselect all selections when the filter or sort changes.

comment:13 Changed 10 years ago by Nathan Toone

Yes - this is exactly the reason why I mentioned that it's moderately difficult to fix. Getting into the "guts" of the grid can be quite a pain at times...

comment:14 Changed 10 years ago by jake richardson

I don't think this is an issue of difficulty, but rather an issue of capability. As far as I see it, there is no way to do identity based virtualized row selection management without the server participating in someway (full server side selection management, or row based identity querying interface), or by obtaining all item identifiers beforehand.

If anyone has a solution in mind that shows otherwise, please sketch it out.

comment:15 Changed 10 years ago by David Schwartz

My $.02: This is a serious usability bug. The user doesn't select 'row 5' but rather 'object XXXXX'. Selection should definitely persist across sort events. This will really tick users off when they discover that their selection is lost.

comment:16 Changed 10 years ago by Nathan Toone

Agreed - this bug *needs* to be addressed...the issue is that it's not a simple enough bug to address in the 1.4 timeframe. Especially given that the issue has existed since the dawn of Grid-time. :)

comment:17 Changed 10 years ago by jake richardson

The above patch does work except for virtual selections (the following scenarios):

  • select all (with the _CheckBoxSelector)
  • select item, scroll over unloaded pages (so it won't load them), shift select

So it should work for most cases, just not when selecting items that have not been loaded.

comment:18 Changed 10 years ago by David Schwartz

So will this remain open until working in all cases?

comment:19 Changed 10 years ago by Nathan Toone

It will at least remain open until it's working in *some* cases... ;)

That is, I haven't applied the patch yet - I'll have to look at it and see what it would take to handle virtual selections. I'm guessing that virtual selections will not be able to be handled...because we don't *know* what items were selected (because they weren't loaded...we don't have their identity).

comment:20 Changed 10 years ago by Nathan Toone

Owner: Nathan Toone deleted

Unassigning my tickets.

comment:21 Changed 8 years ago by evan

Resolution: fixed
Status: newclosed

(In [25579]) Fixes #7304 !strict by leveraging selection persistence across DataGrid?, TreeGrid/LazyTreeGrid?. Refs #10855

The selection persistence feature is still limited with

  1. Key precondition - Store Identifier(id) is required since id is used for differentiating row items.
  1. Known issue - might not be accurate if some unloaded rows are selected by range(e.g.SHIFT + click)

Usage - To turn on this, please set 'keepSelection' attribute to true, e.g. <div dojoType="dojox.grid.DataGrid?" keepSelection = true .../> or

<div dojoType="dojox.grid.TreeGrid?" keepSelection = true .../> or <div dojoType="dojox.grid.LazyTreeGrid?" keepSelection = true .../>

comment:22 Changed 8 years ago by evan

Milestone: future1.7

comment:23 Changed 8 years ago by evan

(In [25580]) Refs #10855 !strict use this.inherited() after the fix of #7304, refs #7304

comment:24 Changed 8 years ago by evan

(In [25668]) Refs #7304 leveraging selection preserver with LazyTreeGrid?, also see [25579]

comment:25 Changed 8 years ago by evan

(In [25740]) Refs #7304 !strict need to reset selectedById[] for deselectAll()

comment:26 Changed 8 years ago by Evan

In [27122]:

Refs #7304, fix a regression caused by [25579] - selection shouldn't be cleared in _clearData() otherwise selections will be lost after being sorted, refreshed etc. Also applied to 1.7.* branch

Note: See TracTickets for help on using tickets.