View Full Version : how to remove a item from a grid

25 Dec 2010, 10:18 PM
Hello there:

I have a grid in my gxt site, which host a bounch of questions. Now at the response to a "delete" button click, the selected question is supposed to be removed from the grid, it didn't happen thou.

This is the snippet I tried:

private ListStore<Question> store = new ListStore<Question>();
ColumnModel cm = new ColumnModel(columnConfigs);

Grid<Question> grid = new Grid<Question>(store, cm);

//the above is to contruct the components
//next is to remove the selected questions...

for (Question q : selList) {

guess I might have incorrectly used store's apis, anyone out there can give me a hand?

Thanks a lot,

26 Dec 2010, 9:24 AM
Removing it from the store should remove it from the grid. Make sure that "q" is really in the store. No need to call update.

26 Dec 2010, 10:07 AM
thanks Sven. So you are saying the code is alright? no more is needed to be done? Other than removing the "update" part?

[update]: checked other people's code (http://www.java2s.com/Code/Java/GWT/GridwithNumberedRowsandForceFitExtGWT.htm), the code is almost identical to mine. Theirs worked. I re-checked my code, and noticed after "remove", the store's count did descrement, but the grid still visually unchanged.