DataGrid with SingleSelection

62 views
Skip to first unread message

Manuel

unread,
Nov 23, 2013, 3:35:28 PM11/23/13
to google-we...@googlegroups.com
Hi everyone,

I wonder whats the right setup for a list that can only have one line selected at a time.
I use a DataGrid with SingleSelection Model and setKeyboardSelectionPolicy.BOUND_TO_SELECTION.

But the behaviour isnt as excepted. For example:
I select a Header to change sorting. This causesthe keyboard selection change to line 0. This causes a selectionChangeEvent.
This can also be looked up in the showcase grid: http://gwt.googleusercontent.com/samples/Showcase/Showcase.html#!CwDataGrid.

I started to setKeyboardSelectionPolicy.DISABLED while handling onRangeChanged - Events and setKeyboardSelectionPolicy.ENABLED after Im done with it.
This works, but I wonder if this is the right way. How you guys implement a single-selection grid.

Regards,
Manuel

jaga

unread,
Nov 25, 2013, 9:56:10 AM11/25/13
to google-we...@googlegroups.com
The right way to manage selection is using a SelectionManager. Try the SingleSelectionManager.

The keyboard selection is something a little different. I actually think keyboard selection in GWT is fairly broken. The boundToSelection setting never seemed to be useful to me. In any case if you enable keyboard selection the cells and rows have an annoying 'third' state. This makes styling difficult when attempting clearly illustrate a row's selection state.

Jaga

Manuel

unread,
Nov 25, 2013, 5:02:09 PM11/25/13
to google-we...@googlegroups.com
I changed my Code. I still use the SingleSelectionModel but changed KeyboardSelectionPolicyis to ENABLED.
I only enabled it to get Up-/Down-Key events to  change the selectedObject in the SelectionModel via Keyboard. I also changed my Style, so I dont see the KeyboardSelection. Thats just what I need and it works really well.
The boundToSelection caused the problems.

Regards,
Manuel
Reply all
Reply to author
Forward
0 new messages