-
9 Feb 2012 12:42 PM #1
How to enable SelectionMode.SIMPLE on CheckBoxSelectionModel in Grid?
How to enable SelectionMode.SIMPLE on CheckBoxSelectionModel in Grid?
Hi,
i try to make multiple rows selectable through checkboxes in a grid without pressing Ctrl or Shift.
I have extracted my problem by this test case:
"sm.setSelectionMode(SelectionMode.SIMPLE);" seems to be completely ignored. Why?Code:public class Test implements EntryPoint{ class Dummy extends BaseModel{ public Dummy() { set("name", "Dummy" ); } } @Override public void onModuleLoad() { ListStore<Dummy> store = new ListStore<Dummy>(); store.add(new Dummy()); store.add(new Dummy()); List<ColumnConfig> columns = new ArrayList<ColumnConfig>(); CheckBoxSelectionModel<Dummy> sm = new CheckBoxSelectionModel<Dummy>(); sm.setSelectionMode(SelectionMode.SIMPLE); columns.add(sm.getColumn()); ColumnConfig cc = new ColumnConfig("name", 100); columns.add(cc); ColumnModel cm = new ColumnModel(columns); Grid<Dummy> grid = new Grid<Dummy>(store, cm); RootPanel.get().add(grid); } }
-
14 Feb 2012 12:35 AM #2
Try This
Try This
i have the same problem and after few shot i solve problem using the following statement
grid.setSelectionModel(sm);
the object "sm" i create like follwing
CheckBoxSelectionModel<YourModelData> sm = new CheckBoxSelectionModel<YourModelData>();
sm.setSelectionMode(SelectionMode.MULTI);
configs.add(sm.getColumn());
-
14 Feb 2012 12:59 AM #3
You need to add selection model to the grid as a selection model and a plugin. Add these two lines of code:
Code:grid.setSelectionModel(sm); grid.addPlugin(sm);
-
14 Feb 2012 1:11 AM #4
Great. Thanks a lot!
That seems very redundant.
1. Pass the ColumnModel containing the SelectionModel to the grid in the constructor.
2. Set the SelectionModel for the Grid.
3. Add the SelectionModel as a plugin.
Anyway i'm glad it works :-)


Reply With Quote