PDA

View Full Version : TreePanel and Expand Event handler



t3q
19 Aug 2009, 6:29 AM
Hello,

I need to catch Expand event from TreePanel. On each expand i want to take ID and update another widget with that ID. I've tried:



TreePanel<Content> tree = new TreePanel<Content>(treeStore);

//tree.setClicksToEdit(ClicksToEdit.TWO);
tree.setBorders(true);
tree.setSize(400, 400);
tree.setDisplayProperty("name");
tree.setStateful(true);
tree.enableEvents(true);
tree.addListener(Events.Expand, new Listener<TreePanelEvent<Content>>() {

public void handleEvent(TreePanelEvent<Content> be) {
Info.display("", "Content ID:" be.getItem().getId(););
}
});
but it doesn't work.

I use GXT 2.0.1.

Arno.Nyhm
19 Aug 2009, 6:39 AM
for me this works. maybe your part for getting the id is wrong


tree.addListener(Events.Expand, new Listener<TreePanelEvent<ModelData>>() {

public void handleEvent(TreePanelEvent<ModelData> be) {
Info.display("", "expanded");
}
});

t3q
19 Aug 2009, 12:38 PM
I've changed "Content" to "ModelData" as you suggested and now it's working. Thanks for advise.

Arno.Nyhm
20 Aug 2009, 3:06 AM
so its fixed by accident. i changed it to ModelData because i dont habe a class Content ;-) only a plain grid with ModelData.

im happy that this helps you.