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

Event for client-side TreeView initialized?

2 Answers 114 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Sebastian
Top achievements
Rank 2
Sebastian asked on 25 Jan 2010, 09:41 AM
Hello,

I currently have this problem: After a postback, I want to display/update additional information about the currently selected node.
The problem is the order of the scripts that are generated. At server side I use this call to render the script that should be executed after the postback:

ScriptManager.RegisterStartupScript(_updatePanel, _updatePanel.GetType(), "UpdateDetails""var treeView = $find('" + _navigationTree.ClientID + "'); UpdateDetailDisplay();"true); 

On Client side, this script gets rendered and executed:

var treeView = $find('ctl00_controlArea_ctl01_ctl04_ctl02'); 
UpdateDetailDisplay(); // internally uses treeView.get_selectedNode(); to read data... 
Telerik.Web.UI.RadTreeView._preInitialize("ctl00_controlArea_ctl01_ctl04_ctl02","0"); 

As you can see, the _preInitialize gets executed *AFTER* my script - which is - of course - totally wrong order. I need the treeview client side object initialized before my call gets executed, because the $find() call returns null in this case.

How can I achieve this?

Using setTimeout is no option. This would a) delay the user interface update and b) I still can't be sure that the TreeView object is fully initialized when the timeout triggers.

Is there a event that is triggered after a postback where I can be sure that the treeview client side object is fully initialized?

Regards,

   Sebastian

2 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 25 Jan 2010, 11:21 AM
Hi Sebastian,

I guess you want to access the treeview client object in the evet handler after postback. If so you can try the following approach.

CS:
 
    protected void Button1_Click(object sender, EventArgs e) 
    { 
        string script = "<script language='javascript' type='text/javascript'>Sys.Application.add_load(UpdateDetailDisplay);</script>"
        ClientScript.RegisterStartupScript(this.GetType(), "showWindow", script);   
    } 

JavaScript:
 
   <script type="text/javascript"
        function UpdateDetailDisplay() { 
            treeView = $find('<%=RadTreeView1.ClientID %>'); 
        }     
   </script> 

-Shinu.
0
Sebastian
Top achievements
Rank 2
answered on 25 Jan 2010, 01:40 PM
That does the trick. The script is executed at a point where I have access to the TreeView client side object. Thank you.
Tags
TreeView
Asked by
Sebastian
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 2
Sebastian
Top achievements
Rank 2
Share this question
or