1

I have a CellList with SingleSelectionModel, My use case is:

  1. User selects one row(oldProxy) in CellList.
  2. User creates one proxy(newProxy) and send to the server.
  3. Client receives the success response and CellList begins to request newest data from server.
  4. CellList filled with newest data, and the row in step 1 is still selected.

But i want to select the the newest row in step 4, i use

selectionModel.setSelected(newProxy);

but seem it does not work and still select the row in step1.

I tried deselect the row before step 2:

selectionModel.setSelected(oldProxy, false);

but at the end it still select the row in step1, it's weird. Any ideas about this?

Mike
  • 3,515
  • 10
  • 44
  • 67
  • Are you sure it's about selection, and not _“keyboard selection”_? Did you try debugging? (e.g. setting a breakpoint in `isSelected` of the selection model and looking at the passed value and callstack?) – Thomas Broyer Apr 30 '13 at 08:06
  • Hello, it's not about "keyboard selection", i did try debugging, after my CellList populated with new data i call `selectionModel.setSelected(newProxy)` but in the probelm is in `resolveChanges()` in SingleSelectionModel, it returned immediately because `newSelectionPending` is false. I think that's because CellList just select the old selected row. I will try to reproduce it later in a craft project. – Mike May 01 '13 at 03:08
  • Hi Thomas, as your hint, the root cause is "keyboard selection", after i debug into the really long `resolvePendingState()` – Mike May 02 '13 at 06:18

2 Answers2

0

Make sure you are passing a key provider (interface ProvidesKey) to the SingleSelectionModel constructor. If you don't use a key provider it will probably use equals() on your proxies to try to find a match, but since you've requested new instances from the server, the old instance will not match any of the new instances.

You can find an example here in the GWT doc.

See also: Select element in CellList using SelectionModel or ListDataProvider

Community
  • 1
  • 1
David Levesque
  • 22,181
  • 8
  • 67
  • 82
0

Turned out to be a known GWT issue6310 , disable the KeyboardSelectionPolicy and it just works as i excepted, Thank Thomas for his great hint and David for the link.

Mike
  • 3,515
  • 10
  • 44
  • 67