Manoj Patil
asked on
JSTree Parent Node Text
Hello Experts,
I am using JSTree plugin to display my Data.
But when I select the Child node, I wanted to get the Parent node Text on form submit.
I have tried below code.
Another issue is when Checked the Parent node, then all child nodes are selected. But I am not getting that selected parent node using below code
var selectedElms =$js('#IndustryTree').jstr ee("get_se lected", true);
This code is working when I particularly select the Child node, in this case, parent node CSS class will be jstree-icon jstree-checkbox jstree-undetermined
Any help would be appreciated
I am using JSTree plugin to display my Data.
But when I select the Child node, I wanted to get the Parent node Text on form submit.
I have tried below code.
$(document).on('click', '#btnSubmit', function () {
var parent = [];
var selectedElms =$js('#IndustryTree').jstree("get_selected", true);
$.each(selectedElms, function () {
selectedElmsIds.push(this.text);
//parent.push(this.parent);
var node = $js('#IndustryTree').jstree(true).get_node(this.parent, true);
var Parentnode = $js('#IndustryTree').find("[id='" + this.parent + "']");
parent.push(Parentnode[0].innerText);
});
});
But When I run this code, in Parentnode[0].innerText I am getting Parent Node text as well as all Child node text. So it is difficult to differentiate the Parent Node Text.Another issue is when Checked the Parent node, then all child nodes are selected. But I am not getting that selected parent node using below code
var selectedElms =$js('#IndustryTree').jstr
This code is working when I particularly select the Child node, in this case, parent node CSS class will be jstree-icon jstree-checkbox jstree-undetermined
Any help would be appreciated
Can you post a piece of the HTML code to work more efficiently?
ASKER
Hi,
I am binding the values from server side in .NET MVC.
So there is just a div to generate the tree.
The main operation is in javascript
I am binding the values from server side in .NET MVC.
So there is just a div to generate the tree.
The main operation is in javascript
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi,
I got the Parent node now when I select the Child node instead of Parent Node.
Now, when I am selecting the Parent node directly, all the child node are selecting, But I am not getting the text values of parent as well as child nodes
How can I get it ?
I got the Parent node now when I select the Child node instead of Parent Node.
Now, when I am selecting the Parent node directly, all the child node are selecting, But I am not getting the text values of parent as well as child nodes
How can I get it ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
The code posted by me is working for me.