Hi, i am trying to get the parent node of the selecetd node by Jquery, i see several properties of prevObjet and also a parentElement but none of them get the parent node of the selected node? Any ideas about this?
Thanks
Hello,
Thank you for contacting Infragistics!
You can get the parent node of a node in the igTree by using the parentNode method:
https://www.igniteui.com/help/api/2014.2/ui.igtree#methods:parentNode
Please let me know if you have any further questions concerning this matter.
Hi, thanks for the replay but this is what i am trying to do and not working.
What i am trying to do is in javascript get the parent node of the selected node, reviewing the page you send me should be something like this:
$("#schemaTree").igTree("parentdNode", $("#schemaTree").igTree("selectedNode"))
right?
"schemaTree" is the id of the treeview.
Any help would be appreciated
Return:
If i use "ui" variable as the selected node then
Hi Oliver,
You need to use the jQuery element of the selected node. You can retrieve it like this:
$("#schemaTree").igTree("selectedNode"))[0].element;
Thank you for using the Infragistics forums!
Didn't understand quite what you say.
I can't use $("#schemaTree").igTree("selectedNode")[0].element because $("#schemaTree").igTree("selectedNode") is an object not an array, any case i can use:
$("#schemaTree").igTree("selectedNode").element[0]
But this return an "li.ui-igtree-node.ui-igtree-parentnode" element but i didnt see where are the values related to the parent node.
If use these object on the $("#schemaTree").igTree("parentdNode", ui.node.element[0]) this didn't return nothing.
Hi again,
You're right, we return the selected node object. Don't dereference the jQuery object of the element and pass it like that:
$("#schemaTree").igTree("selectedNode").element
The parentNode method expects a jQuery element as input. So in your event handler it would look like this:
$("#schemaTree").igTree("parentNode", ui.node.element)
I hope this helps!
Hi, that is the same object i get from the past post i send, i didn't see where on this object are tha text or any other data of the parent node?
if i use the first item of this array i get the same object i mention before "li.ui-igtree-node.ui-igtree-noderoot.ui-igtree-parentnode" and no info about the parent node is on that element.
Hi again Oliver,
The parentNode method returns a jQuery element as stated in the API docs. You can get the node object for that element by calling the igTree nodeFromElement method:
var nodeObject = $("#schemaTree").igTree('nodeFromElement', parentNode);
https://www.igniteui.com/help/api/2014.2/ui.igtree#methods:nodeFromElement
The nodeObject will contain the data, path, and bindings corresponding to the parentNode element.