View Full Version : TreeStore Events - not quite working?

5 Aug 2009, 2:26 PM
Having a weird issue with TreeStore events. I have a workflow which is removing/re-adding content on the TreeStore, and for a user experience issue I'd like the root node of the Tree to be expanded whenever it gets reloaded.

So I figured I'd hook either storeAdd or the storeDataChanged one, however they aren't really working quite right for me.

storeDataChanged isn't seem to be getting called, and storeAdd is generating weird behavior.

Here is my snippet:

store.addStoreListener(new StoreListener<Package>() {
public void storeAdd(StoreEvent<Package> e) {
TreeStore store = grid.getTreeStore();
grid.setExpanded((ModelData) store.getRootItems().get(0), true);

Whenever the data gets reloaded, I end up with a leaf for every expanded node, plus the normal node itself.

It's really strange. Anyone have any ideas on this one?

5 Aug 2009, 2:28 PM
My best guess is that storeAdd is firing on every add event (I am doing a lot in a single add statement), and it is expanding the root node prior to the children nodes getting "added".


10 Aug 2009, 2:26 AM
maybe you can not use the store to trigger an event because you need the items rendered from the store to expand it. otherwise the store is reloaded but the items are still not completly rendered and so you dont see it.

in a grid i have used the event Events.Ready to get the point when all items are rendered.

grid.addListener(Events.ViewReady, new Listener<BaseEvent>() {

public void handleEvent(BaseEvent be) {

see my