4

When I enable keyboard selection policy and multi selection on DataGrid I encountered this problem.

Case 1 : Multi selection through mouse and keyboard

When I want to select more than one row through mouse, I hold Ctrl key or Shift key and this works fine. Through keyboard by default, this action is provided by spacebar. When I want to select serially through keyboard combination of shift key and spacebar does the trick.

Case 2 : Single selection through mouse and keyboard (This is where the problem starts)

When I want to select a single row through mouse, I just do a left click. If I don't hold either of ctrl of shift key and do a left click, even if the multiple rows are selected, it will get deselected and only the current row gets selected. This is the expected behavior and I don't have any issue with it.

But the same thing is not achievable through keyboard. There is no way to select a single row through keyboard. If I press spacebar a row gets selected and if I press the spacebar again on some other row without shift/ctrl key, it gets multi selected and previous selected row doesn't get deselected.

My question is : How to achieve single selection through keyboard similar to that of mouse?

EDIT : I opened this issue in gwt issues. I hope they respond to this.

Abhijith Nagaraja
  • 3,370
  • 6
  • 27
  • 55

1 Answers1

5

You have to use a custom selection event manager whose translator returns the appropriate value for the behavior you want from clearCurrentSelection.

The default behavior is to always add/remove from selection from the keyboard, and use the control or meta key to toggle whether to clear the current selection when using the mouse.

Thomas Broyer
  • 64,353
  • 7
  • 91
  • 164
  • I will definitely try this approach. I have a question though. Shouldn't my expectation should be default behaviour? Anywhere in the web or desktop application, unless you hold on some additional key like ctrl or shift, shouldn't it be always a single selection? Should I create a issue in gwt issue list regarding the same or is there any specific reason why it is designed like that – Abhijith Nagaraja Mar 09 '13 at 11:58
  • I have absolutely no idea. Feel free to open an issue, but be prepared to wait for a long time. Those kind of things, particularly when there are workarounds, are lower priority. Back you issue with _on the wild_ examples of what you think should be the correct behavior. – Thomas Broyer Mar 09 '13 at 12:59