PDA

View Full Version : TreePanel - TreePanelEvent - get node



fother
14 Jul 2009, 5:02 AM
click in one item in the tree... will return the stack trace below

code example


Folder model = TestData.getTreeModel();

final TreeStore<ModelData> store = new TreeStore<ModelData>();
store.add(model.getChildren(), true);

final TreePanel<ModelData> tree = new TreePanel<ModelData>(store);
tree.setDisplayProperty("name");
tree.setWidth(250);
tree.setCheckable(true);
tree.setCheckStyle(CheckCascade.NONE);
tree.addListener(Events.CheckChange, new Listener<TreePanelEvent<ModelData>>() {

public void handleEvent(TreePanelEvent<ModelData> be) {

System.out.println(be.getNode());
}
});


stack trace


com.google.gwt.core.client.JavaScriptException: (TypeError): 'srcElement' é nulo ou não é um objeto
number: -2146823281
description: 'srcElement' é nulo ou não é um objeto
at com.google.gwt.dom.client.DOMImplIE6.eventGetTarget(Native Method)
at com.google.gwt.dom.client.NativeEvent$.getEventTarget$(NativeEvent.java:109)
at com.extjs.gxt.ui.client.event.TreePanelEvent.getNode(TreePanelEvent.java:78)
at com.extjs.gxt.ui.client.event.BaseObservable.callListener(BaseObservable.java:176)
at com.extjs.gxt.ui.client.event.BaseObservable.fireEvent(BaseObservable.java:96)
at com.extjs.gxt.ui.client.widget.Component.fireEvent(Component.java:444)
at com.extjs.gxt.ui.client.widget.treepanel.TreePanel.setChecked(TreePanel.java:643)
at com.extjs.gxt.ui.client.widget.treepanel.TreePanel.onCheckClick(TreePanel.java:1050)
at com.extjs.gxt.ui.client.widget.treepanel.TreePanel.onClick(TreePanel.java:1067)
at com.extjs.gxt.ui.client.widget.treepanel.TreePanel.onComponentEvent(TreePanel.java:548)
at com.extjs.gxt.ui.client.widget.Component.onBrowserEvent(Component.java:760)
at com.google.gwt.user.client.DOM.dispatchEventImpl(DOM.java:1320)
at com.google.gwt.user.client.DOM.dispatchEventAndCatch(DOM.java:1299)
at com.google.gwt.user.client.DOM.dispatchEvent(DOM.java:1262)

fother
14 Jul 2009, 5:33 AM
I dont know if its one issue, because can be solved using this



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

public void handleEvent(TreePanelEvent<ModelData> be) {

ModelData p = store.getParent(be.getItem());

System.out.println(p.get("name"));
}
});