This is a migrated thread and some comments may be shown as answers.

Treeview as AJAX Rendered Control -Client side API .Nodes issue

2 Answers 36 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Bob Glamm
Top achievements
Rank 1
Bob Glamm asked on 26 May 2010, 05:02 PM
When I use Rad treeview as a server side rendered control thru AJAX, none of the clinet sideProperties seem to work, all other functionality seem to work. Please see the Javascript code sample below ( the errors are shown in comment )

function get_checkedNodes_LEAF(tree) {
         var checkedNodes = [];
//error description below
// tree.AllNodes does not work, Javascript error .AllNodes not defined
// but the below get method works
         var allNodes = tree.get_allNodes();
         for (var i = 0, j = 0; i < allNodes.length; i++) {           
         //eliminate partially checked nodes
             if (allNodes[i].get_checkState() == 1) {
                  //   error description below
                 //     allNodes[i].Nodes gives  Javascript error .Nodes not defined             
                 //     also allNodes[i].get_nodes() returns undefined
                checkedNodes[j] = allNodes[i];               
                 j++;
             }
         }
         return checkedNodes;       
     }

I would need to find only leaf nodes that are checked so I would need to
use node.Nodes.length == 0 check which does not work.

Can anybody help?
Thanks for your support.

Thanks,
Sanjev


2 Answers, 1 is accepted

Sort by
0
Accepted
Veronica
Telerik team
answered on 01 Jun 2010, 08:34 AM
Hi Bob Glamm,

I've created a sample solution for you.

You can get all checked nodes for the TreeView control and then iterate through them to find the leaf nodes only. Here's the code:

function get_checkedLeafNodes(sender, args) {
            var tree = sender;
            var checkedLeafNodes = [];
            var checkedNodes = tree.get_checkedNodes();
            for (var i = 0; i < checkedNodes.length; i++) {
                if (checkedNodes[i].get_nodes().get_count() == 0) {
                    checkedLeafNodes[i] = checkedNodes[i];
                    alert(checkedLeafNodes[i].get_text());
                }
            }
        }

You can use this help topic always to see what are the available methods and properties for the RadTreeView and RadTreeNode objects client-side.

Find the full code in the attached .zip file and let me know if this was helpful.

Regards,
Veronica Milcheva
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Bob Glamm
Top achievements
Rank 1
answered on 01 Jun 2010, 05:47 PM
Thanks Veronica Milcheva,
This works, I am marking this as answered so it would be useful for others.
Tags
TreeView
Asked by
Bob Glamm
Top achievements
Rank 1
Answers by
Veronica
Telerik team
Bob Glamm
Top achievements
Rank 1
Share this question
or