PDA

View Full Version : Problem in using grid and CheckBoxSelectionModel



eudoxem
4 Aug 2010, 5:31 AM
I'm having a problem in using a Grid with CheckBoxSelectionModel. I search on the forum and it seems like nobody has had the problem. I compare with the samples of the showcase but I can't find what I'm doing wrong.

I have a grid on which I plug a CheckBoxSelectionModel in order to select some items of my list. The grid is correctly loaded and the checkboxes are available. The issue is that I can only select/deselect the first item. When I select the Select all/ Deselect all checkbox, the behaviour is similar.

I attach a snippet


ContentPanel cp = new ContentPanel();
cp.setAnimCollapse(false);
cp.setHeading(constants.transport());

RpcProxy<ListLoadResult<TransportView>> proxy = new RpcProxy<ListLoadResult<TransportView>>() {

@Override
protected void load(Object loadConfig, AsyncCallback<ListLoadResult<TransportView>> callback)
{
ListLoadConfig listLoadConfig = (ListLoadConfig) loadConfig;
listLoadConfig.set("identifier", 1);
userService.getFleetTransports(listLoadConfig, callback);
}
};

// Le loader
final ListLoader<ListLoadResult<TransportView>> loader = new
BaseListLoader<ListLoadResult<TransportView>>(proxy);
loader.load();

// Le store
ListStore<TransportView> store = new ListStore<TransportView>(loader);

// Creation de la colonne
List<ColumnConfig> configs = new ArrayList<ColumnConfig>();

CheckBoxSelectionModel<TransportView> sm = new CheckBoxSelectionModel<TransportView>();
sm.setSelectionMode(SelectionMode.MULTI);

configs.add(sm.getColumn());
ColumnConfig column = new ColumnConfig("name", "Name", 100);
configs.add(column);

ColumnModel cm = new ColumnModel(configs);
Grid<TransportView> grid = new Grid<TransportView>(store, cm);
grid.setBorders(true);
grid.setAutoHeight(true);
grid.setSelectionModel(sm);
grid.addPlugin(sm);

cp.add(grid);

I'm using GXT 2.1.1

eudoxem
5 Aug 2010, 12:30 AM
I finally find what I'm doing wrong. My ModelData (TransportView) has override hashCode and equals methods and the comparison is made on a particular field on which I don't set value. So the items were considered equals although they were not. Thanks

I also think that this thread could be closed!