PDA

View Full Version : Set all rows in grid to be selected



jpartogi
14 Oct 2009, 2:50 AM
Hi all,

I'd like to have a grid which by default having the all checkboxes checked. I have added the CheckBoxSelectionModel as the selection model to the grid and call the selectAll method on the SelectionModel, but does not work.


Grid<CepForm> grid = new Grid(store, cm);
CheckBoxSelectionModel<MyModel> sm = new CheckBoxSelectionModel<MyModel>();
grid.setSelectionModel(sm);
sm.selectAll();


So how do we suppose to do this in GXT? Am I missing something here?

Many thanks in advance.

brigham.bell
4 Nov 2009, 10:16 AM
I also had difficulty with this, but was able to get it working by doing the following two things:


Wrap the selectAll in a DeferredCommand:


DeferredCommand.addCommand(new Command() {
public void execute() {
grid.getSelectionModel().selectAll();
}
});

Make this call after the grid is added to the UI. (e.g. the very last thing that is done in EntryPoint.onModuleLoad()).