Hi,
Can anyone let me know how to get all the nodes in javascript when button click.
i need the function to get all the node in button click but get_checkedNodes will be in checked change event of tree view . how can i get the get the checked nodes in treeview without any treeview events.
i have been using the following code but it error is comming,
var nodes = new Array;
var tree = document.getElementById('ctl00_ContentPlaceHolder1_WebTab1_tmpl0_WebDataTree1');
nodes = tree.get_checkedNodes();
var CompGuid = "";
for (var i = 0; i < nodes.length; i++) {
if (nodes[i].get_checkState == 1) {
//if (CompGuid.length > 0) {
CompGuid += ",";
//}
CompGuid += nodes[i].value;
}
Thanks in Advance.
Hi anilkoomar_1202,
Thank you for posting in the community.
In order to access the WebDataTree object on the client either $find or the ig_controls object can be used. For instance:
var tree = $find('<%= WebDataTree2.ClientID %>'); var tree = ig_controls.ContentPlaceHolder1_WebDataTree2;
var tree = $find('<%= WebDataTree2.ClientID %>');
var tree = ig_controls.ContentPlaceHolder1_WebDataTree2;
Please let me know if this helps.
Hi Petar Ivanov,
Thanks For your Quick Reply,
can u provide me a sample to get the checked nodes in the webdatatree without using any webdatatree events. i need to get the checked nodes data on button click in javascript
Attached is a sample illustrating the configuration you have requested.
i have been usoing the following
nodes[i].get_checkState
to get Checked status but is coming as undefined.
Thanks in advance
Can you confirm that the node itself is accessible, i.e. nodes[i] , as the get_checkState() function is returning 1 when I am testing my sample (as expected) ?
Thank you for your reply. Glad that the matter has been resolved.
Please feel free to contact me if you have any further questions regarding this matter.
Thanks it helps me.code is working.
Thank You
Note that get_checkState is a function and not a property, i.e the above code should look like:
for (var i = 0; i < nodes.length; i++) { if (nodes[i].get_checkState() == 1) { CompGuid += nodes[i].value+","; } }
if (nodes[i].get_checkState() == 1) {
CompGuid += nodes[i].value+",";
Hope this helps.
i was unable to get it.i was using the following code for retriving the node value. i was using v11.1
Thanks in Advance