Sunday, September 22, 2013

Re: DataGrid, updateRowData and setSelected

SingleSelectionModel only fires a single selection event at the end of the current browser event loop and it does so only if the selection state has actually changed. That means if you execute the following code

// assume "currentRecord" is currently selected
selectionModel.setSelected(currentRecord, false)
selectionModel.setSelected(currentRecord, true)
selectionModel.setSelected(currentRecord, false)
selectionModel.setSelected(currentRecord, true)

you will receive no event because after all these 5 code lines are executed the selection state inside the selectionModel hasn't changed as currentRecord is still selected. In your above example if "null" or "nothing" is currently selected you won't receive any event because selectionModel.setSelected(null, true) updates the selection model to the state it already has. If anything except null is currently selected you should receive a selection event because you change the selection from "anything except null" to "null".


When you press your prepare button you should only call selectionModel.clear() and once your find() method is finished you should call selectionModel.setSelected(foundEntity, true). Nothing more, nothing less. Also you should first update your rows and then update the selection.


-- J.

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment