Team,
I have a need to be able to read text from an array of selected children (supposedly available using the 'children' method). Is there any way to access this array to do this?
Thanks,
Walter Sobchak
To clarify, this needs to be children of a selected node. I seem to be able to access the checked status by using nodeByIndex but cannot access the data.Text or html properties to read the inner text of the nodes.
To Update the above, I've found the "children" method of selecting by a node as parameter does not seem to work. I've resorted to using"childrenByPath" which has the desired result of accessing the set of children for manipulation.
Could someone from the IG team clarify why the children method may have problems and the childrenByPath doesn't?
Hello Big_Lebowski,
Thank you for contacting Infragistics community.
As far as I understood your explanation, you want to get the text of any selected node's child node. Is that right?
If this is the case, then I would suggest you to do that on selectionChanged event, for instance:
selectionChanged: function (evt, ui) {
// this will return "United States" as result based on the following sample code - http://igniteui.com/tree/overview var childNodeText = ui.selectedNodes[0].element[0].children[2].children[0].children[0].innerHTML; }
I'm attaching also a sample for your reference. Please let me know if you have any further questions.
Sincerely,
Tsanna
In the project, when a node is added, a string is appended with the value. Once the node is removed, the text values must be read and removed from the string. I was able to accomplish this using the following:
function removeNode(whichTree, whichHF) { var node = $(whichTree).igTree("selectedNode"); var nodeChildren = $(whichTree).igTree("childrenByPath", node.path); //alert(nodeChildren.length); var replaceStr = node.data.Text; var idx = 0; if (nodeChildren.length > 0) { while (idx < nodeChildren.length) { // Get root nodes. var nestedNode = nodeChildren[idx].data.Text; replaceStr += nestedNode; //alert(replaceStr); idx++; } } //alert(replaceStr); replaceText(whichHF, replaceStr, ""); if (node.path != null) { // Remove selected node using path $(whichTree).igTree("removeAt", node.path); $(whichTree).igTree("clearSelection"); } }