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

TreeView and UpdatePanel

2 Answers 186 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Reiner Ebel
Top achievements
Rank 1
Reiner Ebel asked on 17 Oct 2009, 03:05 PM
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 Answers, 1 is accepted

Sort by
0
Reiner Ebel
Top achievements
Rank 1
answered on 18 Oct 2009, 09:15 AM
I have set the UpdateMode - Conditional. 
Unfortunately, it did not work.
0
Yana
Telerik team
answered on 22 Oct 2009, 09:34 AM
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.
Tags
TreeView
Asked by
Reiner Ebel
Top achievements
Rank 1
Answers by
Reiner Ebel
Top achievements
Rank 1
Yana
Telerik team
Share this question
or