rcheuk
rcheuk

Reputation: 1140

EXT GWT Bind Selected Items to a new empty grid

I am using one grid to select items, and another to display the selected items. I am having trouble updating the new grid.

In pseudo code:

selectionGrid = new Grid();

selectionGrid.addlistener(new listener {
    update();
});

void update() {

targetGrid = new Grid(selectionGrid.getstore().getselecteditems(), columns);
}

I'm able to update the targetgrid the first time, but have trouble updating it again after a new selection.

Is there a different way I should be doing this?

Thanks.

Upvotes: 1

Views: 563

Answers (1)

Colin Alworth
Colin Alworth

Reputation: 18331

That's pretty much it - make the two grids, one with the original items, the other with an empty ListStore. The update call should store.addAll(selected), though probably store.clear() first.

These methods assume GXT 3 - in GXT 2, I think it is store.add(selected) and store.removeAll(). In 2 you may also find that the Events.SelectionChange isn't fired by Grid, but by it's SelectionModel - read the javadoc to be sure what events each class fires. In GXT 3, the events are made clear by the exposed HasSelectionHandlers interfaces, indicating that you can add a handler for selection events.

If this still doesn't work, consider posting an almost working example to demonstrate exactly what you've tried.

Upvotes: 1

Related Questions