jQuery UI Widgets › Forums › Navigation › Tree › How to get all child nodes by it’s parent
Tagged: child, children, expand, get, initialize, initialized, jqxtree, node, select, Tree
This topic contains 8 replies, has 3 voices, and was last updated by Dimitar 10 years, 10 months ago.
-
Author
-
Hi, it’s the first time for me using jqxTree.. It was so great.
I want to ask some questions. I have a tree like this :
Root
—–Child 1
————- Data a
————- Data b
————- Data c
—–Child 2
————- Data d
————- Data e
————- Data f
—–Child 3
————- Data g
1. How to get all child nodes by it’s parent. For example when I check child 2, then it return Data d, data e, and data f ?
2. Is it possible to disable node select in a tree ? I mean, when I double click on a node, the tree was expand.. how to disable double click in a node, so it wouldn’t expand node ?
thx before..
Hello yehezqiel,
Here is how to get the descendants of a selected node:
$('#jqxTree').on('select', function (event) { var e = event.args.element; var children = $(e).find("li"); });
There is now way of disabling a particular node select, except for the disableItem method.
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/Thank’s Dimitar.. it works..
Can I ask again ? 😀
In Api Reference, Initialize events was : “The initialized event is triggered when the jqxTree is created and initialized.”
I put an alert method in initalized code, but when the tree was appear in browser, there is no alert appear.. Is initialize is an event that was first run ?
thx before..
Hi yehezqiel,
The initialized event code should be put before the initialization of the tree itself.
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/Thank you so much Dimitar… GBU
I have a questions again.. could you help me again, please :D. Should I create a new topic or post in here ?
I have a checkboxtree. When I check some item, or expand some node and then I submit the form into server. I want to display the same tree as before I submit the form.
I’m using JSP+Java, so in server i create a string with checked:true, expanded: true.. The tree was successfully checked, but not with expanded.. it was expand, but there is no ajax load.. just show “Loading”..
Could you show me to expand some node after the jqxTree is created and initialized.
thx…
Solved… I’m using $(window).load() to expand choosen node after tree has been created
Hi yehezqiel
Can u tell me how to get the children nodes from parent?
I used the same code here, but it is returning as objects and I am not able to get the values from it.
Tx in advance…
Breetty
Hello Breetty,
The proposed approach is suitable for getting the the HTML elements of the node’s children. Here is how to modify the code to alert the labels of these children. Note that it works correctly only if they do not have children of their own.
$('#jqxTree').on('select', function (event) { var e = event.args.element; var children = $(e).find("li"); var childrenLabels = new Array(); for (var i = 0; i < children.length; i++) { childrenLabels.push(children[i].innerText); }; alert(childrenLabels); });
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/ -
AuthorPosts
You must be logged in to reply to this topic.