Tuesday, July 24, 2018

Re: GWT Single Selection Model to prevent having all records unchecked in Cell List.



On Monday, July 23, 2018 at 6:17:58 PM UTC+2, BM wrote:
I have GWT cell list with single selection model and checkbox which is one of the selection column. So it does toggle between rows since it acquires single section model. 

The toggle should function AS-IS but what I want is if one clicks on an already selected row, the selection should not uncheck that row. If they click on second row, the selection should move to second row which is fine. 

How do we do this?

You'd need a specific SelectionModel that would "refuse" to unselect the selected item.
It might be as simple as extending SingleSelectionModel, overriding setSelected(T,boolean) to do nothing when 'selected' is 'false'; or you may have to write your own SelectionModel (inspired by the SingleSelectionModel)

Alternatively, I suppose you could also achieve your goal with a specific EventTranslator that wouldn't toggle the selection on an already selected item (instead of using DefaultSelectionEventManager.createCheckboxManager(), use a new DefaultSelectionEventManager(new MyEventTranslator()); you could possibly wrap a CheckboxEventTranslator and return IGNORE on an already-selected item –event.getDisplay().getSelectionModel().isSelected(event.getValue())– instead of delegating to the CheckboxEventTranslator, which could then only return TOGGLE on an unchecked checkbox)

--
You received this message because you are subscribed to the Google Groups "GWT Users" 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 https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment