View Full Version : Refresh Grid and retain checkbox selections.
polloelastico
13 Aug 2009, 3:12 PM
I am using the BasePagingLoader, ListStore and a CheckBoxSelectionModel. I have also added a timer to refresh the grid every N seconds using the loader.load method. However, if there were any items selected and checked they are unselected on the refresh. Can someone recommend a solution to this issue? Thank you.
fother
13 Aug 2009, 3:27 PM
its simple..
before load the loader - get Items selected
after load the loader - get the items selected and selected in the grid again
polloelastico
13 Aug 2009, 3:40 PM
So you are suggesting?
List<MyObject> items = sm.getSelectedItems();
// refresh
loader.load();
// repopulate the selected items.
sm.select(items, true);
This doesn't work for me. Thanks,
loading is asynchron. You need to listen to the load event and reselect the entries there.
polloelastico
13 Aug 2009, 4:03 PM
Thanks, that makes sense. However, the following code still does not select the items in the Model.
loader.load();
loader.addLoadListener(new LoadListener() {
@Override
public void loaderLoad(LoadEvent le) {
sm.select(items, true); // SelectionModel
}
});
fother
13 Aug 2009, 4:28 PM
of course.. because the models its diferent when you load, load and load again..
you need implements..
example
grid.getStore().setModelComparer(new ModelComparer<EntidadeTreeModel>() {
@Override
public boolean equals(final MYModel m1, final MYModel m2) {
boolean aaa = m1.get("key");
boolean bbb = m1.get("key");
return aaa && bbb;
}
});
fother
13 Aug 2009, 4:30 PM
or not :))
debug your code and test.. or provide a test case.. its more easy for all :)
Arno.Nyhm
14 Aug 2009, 8:21 AM
should it be more like this?
grid.getStore().setModelComparer(new ModelComparer<EntidadeTreeModel>() {
@Override
public boolean equals(final MYModel m1, final MYModel m2) {
KeyObjectType k1 = m1.get("keycolumn");
KeyObjectType k2 = m2.get("key");
return k1.equals(k2); // if its string. if it is integer then k1 == k2
}
});
[/quote]
Powered by vBulletin® Version 4.1.5 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.