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

Extra information with expand()

2 Answers 45 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
FU
Top achievements
Rank 2
FU asked on 18 Feb 2010, 02:29 PM
Is it possible, from Javascript, to pass an extra parameter along with the expand()-function to the serverside OnNodeExpand-method?

I'm building a tree using TreeNodeExpandMode.ServerSideCallBack and trying to implement an 'Expand all'-function in the contextmenu. I want to add the branch on the serverside instead of multiple calls to expand(). This all works well, except I can't differentiate the 'default' OnNodeExpand-event from the 'expand all'-event. I've tried using a textfield but as it's an Ajax-request it is not transferred to the server. I've also tried setting a custom attribute on the RadTreeNode but, again, it seems this isn't transferred. Any ideas?
 
I'm using the expand()-function because I'd like to preserve the loading-animation.

 

2 Answers, 1 is accepted

Sort by
0
Accepted
Yana
Telerik team
answered on 19 Feb 2010, 01:27 PM
Hello Mickey13,

The approach with custom attributes should work, please subscribe to OnClientNodePopulating event of the treeview and in its handler:

<script type="text/javascript">
       function nodePopulating(sender, args) {
           var node = args.get_node();
           sender.trackChanges();
           node.get_attributes().setAttribute("attr", "value");
           sender.commitChanges();
       }
</script>

and then you can get the attribute in OnNodeExpand event like this:

protected void treeView1_NodeExpand(object sender, RadTreeNodeEventArgs e)
{
    var attrValue = e.Node.Attributes["attr"];
}

Greetings,
Yana
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
FU
Top achievements
Rank 2
answered on 25 Feb 2010, 10:09 AM
That worked. trackChanges/commitChanges made the difference.
Tags
TreeView
Asked by
FU
Top achievements
Rank 2
Answers by
Yana
Telerik team
FU
Top achievements
Rank 2
Share this question
or