问题
I use following methods :
var myobj = myTree.getSelectionModel().getSelection();
alert(myobj) // [Object object]
Now, i don't know what i can do it with this object. I supposed this Object have my value ? But i don't know how to use Object to retrieve values ... !
Thanks a lot :)
回答1:
First. Looking at the API, I think the method you are talking about is
// DefaultSelectionModel:
var myobj = myTree.getSelectionModel().getSelectedNode();
// MultiSelectionModel:
var myobj = myTree.getSelectionModel().getSelectedNodes();
which returns an object or array of type TreeNode.
Second. I will advice you to use a client side debug tool like FireBug or similar to actually see what you get when calling myTree.getSelectionModel().getSelection(). If the result is a TreeNode item then check the API for information about the different properties.
Hope it helps you :)
来源:https://stackoverflow.com/questions/6265570/how-i-can-retrieve-value-from-selected-node-on-tree-panel