PDA

View Full Version : Create a grid with all rows selected at opening



alessalessio
8 Mar 2011, 4:10 AM
I searched through the forum ,but actually i didn't find a solution to this.

I have a Grid with a certain number of records and a CheckBoxSelectionModel.
What i want to do is to see all the rows selected after the grid is rendered.


Actually, this is the code i use but does not do to job.


Grid<ModelData> grid = new Grid<ModelData>(TestData.getStore(), TestData.getColumnModel());

final CheckBoxSelectionModel<ModelData> sm = new CheckBoxSelectionModel<ModelData>();
sm.setSelectionMode(SelectionMode.SIMPLE);

grid.setSelectionModel(sm);
grid.selectionModel.selectAll();


I tried to fire the event Events.HeaderClick after setting the selection model but it doesn't fire at all :)

Where is the mistake?


thanks for the help

alessalessio
8 Mar 2011, 6:47 AM
Seems that the only way to do this is only when the Grid is attached ..



@Override
protected void onAttach() {
super.onAttach();
selectionModel.selectAll();
}


Here it works.