TreeView and UpdatePanel

3 posts, 0 answers
  1. Reiner Ebel
    Reiner Ebel avatar
    15 posts
    Member since:
    Jul 2009

    Posted 17 Oct 2009 Link to this post

    Hello,

    I have a RadTreeView in a UpdatePanel and a RadListView in another UpdatePanel. I must expanded the parent nodes to the right childnode. When i clicked on the childnode, then i load a details from webservice in the ListView in the other UpdatePanel. This works fine.

    The problem is, after i clicked on the childnode and loaded the details, the TreeView is unexpanded and the childnode is deselcted. How can I solve my problem?

    Here is my code:

    <asp:UpdatePanel ID="UpdatePanel2" runat="server" onload="UpdatePanel2_Load">  
                <ContentTemplate> 
                    <telerik:RadTreeView ID="rtvLayoutListe" runat="server" AutoPostBack="true" Height="450px"   
                        Skin="Office2007" OnClientNodeClicking="ClientClickHandler"    
                        oncontextmenuitemclick="rtvLayoutListe_ContextMenuItemClick"             
                        OnNodeClick="rtvLayoutListe_NodeClick"   
                        onclientcontextmenuitemclicking="ContextMenuClicking"   
                        onclientnodeclicked="ClientClickedHandler"
                    .....

                        </

     

    ContextMenus 

     

     

                    </telerik:RadTreeView

     

     

                </ContentTemplate 

     

     

    </asp:UpdatePanel>
    ...

    <

     

    asp:UpdatePanel ID="UpdatePanel1" runat="server">  

     

     

     

    <Triggers>
    <asp:AsyncPostBackTrigger ControlID="rtvLayoutListe" EventName="NodeClick" />

     

    </Triggers>

     

    <ContentTemplate>
    <h3><asp:Label ID="lblContainerNameH3" runat="server" Text=""></asp:Label></h3> 
    <telerik:RadListBox ID="rlbObjectList" runat="server" AllowDelete="True"  

    AllowReorder="True" CssClass="rlbObjects" Skin="Office2007" Width="400px"  
    onitemdatabound="rlbObjectList_ItemDataBound">  

     

    <ButtonSettings ShowTransfer="False" ShowTransferAll="False" /> 

    </telerik:RadListBox>
    ...

     

     

     

     

     

     


    Javascript:
    function ClientClickHandler(sender, eventArgs) {  
                var node = eventArgs.get_node().get_value();  
                if (!node.startsWith("container-")) {  
                    eventArgs.set_cancel(true);  
                    return false;  
          }  

    C#:

    protected

     

    void UpdatePanel2_Load(object sender, EventArgs e) 

    {

        GenerateTreeView();

    }

     


    public

     

    void GenerateTreeView() 

     

     

    {

    rtvLayoutListe.Nodes.Clear(); 

     

    layoutsql lsql = new layoutsql(); 

     

    DataSet ds = lsql.GetLayoutsForManager();  

     

    ...
    }

    protected void rtvLayoutListe_NodeClick(object sender, RadTreeNodeEventArgs e)  
        {  
            if (e.Node.Value.StartsWith("container-"))  
            {  
                lblContainerNameH3.Text = "Container: " + e.Node.Text;  
                objectssql osql = new objectssql();  
                rlbObjectList.DataSource = osql.LoadCurrentContainers(int.Parse(e.Node.Value.Substring(10)));  
                rlbObjectList.DataBind();  
                lblContainerNameH3.Text += " - Time: " + new TimeSpan(0, 0, timecounter).ToString();  
            }  
            else  
            {  
                lblContainerNameH3.Text = "";  
            }  
        } 

    I saw, after the click on the Node - the UpdatePanel makes a new load. 

    How can I prevent a reload of the UpdatePanel?

    Reiner
  2. Reiner Ebel
    Reiner Ebel avatar
    15 posts
    Member since:
    Jul 2009

    Posted 18 Oct 2009 Link to this post

    I have set the UpdateMode - Conditional. 
    Unfortunately, it did not work.
  3. Yana
    Admin
    Yana avatar
    5013 posts

    Posted 22 Oct 2009 Link to this post

    Hi Reiner,

    The problem is that you bind the treeview on every postback, please modify you UpdatePanel2_Load method like this:

    protected void UpdatePanel2_Load(object sender, EventArgs e)
    {
        if(!IsPostBack)
            GenerateTreeView();
    }

    Greetings,
    Yana
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top