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

RadTreeView in RadComboBox causes full (non-AJAX) Postback

6 Answers 99 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Jay
Top achievements
Rank 1
Jay asked on 29 Oct 2008, 05:54 PM
I've embedded a RadTreeView in a RadComboBox much like the online example, except that I've added event handlers to the RadTreeView for the NodeClick event.  I've also wrapped all of this in an AJAX Panel to avoid causing a full page post-back.  But, it seems like the RadTreeView simply ignores this AJAX wrapper and causes a full page post-back anyway.

I've included a code sample:
<%@ Page Language="C#" %> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
 
<script runat="server"
    protected void TreeView_SelectedIndexChanged( object sender, EventArgs e ) 
    { 
        RadTreeView rtv = (RadTreeView) sender; 
        RadComboBoxItem item = CB1.SelectedItem; 
        item.Text = rtv.SelectedNode.Text; 
        item.Value = rtv.SelectedValue; 
    } 
 
    protected void ComboBox_SelectedIndexChanged( object sender, EventArgs e ) 
    { 
        RadComboBox rcb = sender as RadComboBox; 
        LIT1.Text = rcb.SelectedItem.Text; 
    } 
</script> 
 
<html xmlns="http://www.w3.org/1999/xhtml"
<head runat="server"
    <title></title
</head> 
<body> 
    <form id="form1" runat="server"
    <asp:ScriptManager ID="Mgr1" runat="server"></asp:ScriptManager> 
 
    <telerik:RadAjaxPanel ID="RAP1" runat="server" EnableAJAX="true"
        <telerik:RadComboBox ID="CB1" runat="server" AutoPostBack="true"
            <ItemTemplate> 
                <telerik:RadTreeView ID="TV1" runat="server" OnNodeClick="TreeView_SelectedIndexChanged"
                    <Nodes> 
                        <telerik:RadTreeNode Text="Node 1" Value="1"></telerik:RadTreeNode> 
                        <telerik:RadTreeNode Text="Node 2 - Parent" Value="1"
                            <Nodes> 
                                <telerik:RadTreeNode Text="Node 2.1" Value="2.1"></telerik:RadTreeNode> 
                                <telerik:RadTreeNode Text="Node 2.2" Value="2.2"></telerik:RadTreeNode> 
                            </Nodes> 
                        </telerik:RadTreeNode> 
                        <telerik:RadTreeNode Text="Node 3" Value="3"></telerik:RadTreeNode> 
                    </Nodes> 
                </telerik:RadTreeView> 
            </ItemTemplate> 
            <Items> 
                <telerik:RadComboBoxItem Text="None" Value="" /> 
            </Items> 
        </telerik:RadComboBox> 
    </telerik:RadAjaxPanel> 
     
    <telerik:RadAjaxPanel ID="RAP2" runat="server" EnableAJAX="true"
        <telerik:RadComboBox ID="CB2" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ComboBox_SelectedIndexChanged"
            <Items> 
                <telerik:RadComboBoxItem Text="Item 1" Value="1" /> 
                <telerik:RadComboBoxItem Text="Item 2" Value="2" /> 
                <telerik:RadComboBoxItem Text="Item 3" Value="3" /> 
            </Items> 
        </telerik:RadComboBox> 
        <asp:Literal ID="LIT1" runat="server">Item Value</asp:Literal> 
    </telerik:RadAjaxPanel> 
    </form> 
</body> 
</html> 
 

I included the second RadComboBox just to show that the AJAX panel works for simpler controls.


6 Answers, 1 is accepted

Sort by
0
Jay
Top achievements
Rank 1
answered on 29 Oct 2008, 06:51 PM
I just found an entry on this in your troubleshooting pages and will attempt to include the "attachDropDown" method to see if I can fix this.
0
Jay
Top achievements
Rank 1
answered on 30 Oct 2008, 12:24 AM
I used the attachDropDown method, which worked for the particular sample by adding a bit of client-side script.  But, were I to use this method in a custom control to embed within a page potentially multiple times, the
$find( "<%= CB1.ClientID %>" ) 
call would not work (consistently).  And, as I found, adding the attachDropDown call on the RadComboBox's client load event doesn't work at all, either.
0
Accepted
Rosi
Telerik team
answered on 30 Oct 2008, 08:00 AM
Hi Jay,

I suggest you call the attachDropDown() method of RadComboBox in the event handler of OnClientNodeClicking of RadTreeView.

Hope this helps.

Kind regards,
Rosi
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Jay
Top achievements
Rank 1
answered on 31 Oct 2008, 06:53 PM
The attachDropDown call does work in the OnClientNodeClicking handler, but if I include these control in a custom control, which I replicate multiple times in a page, the $find function ceases to produce predictable results, since the page has mutiple script blocks with functions having the same name, so we won't know which version of the function the Javascript engine will call.  So, the attachDropDown does solve the problem in simple single-use situations, but we can't use it this way reliably in more complex applications.
0
Veselin Vasilev
Telerik team
answered on 03 Nov 2008, 01:03 PM
Hi Jay,

I believe that this KB article will help you in your complex scenario:
(ID#921) Using dynamic/unique names for JavaScript functions

All the best,
Veselin Vasilev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Jay
Top achievements
Rank 1
answered on 03 Nov 2008, 08:04 PM
Thanks for the link!
Tags
TreeView
Asked by
Jay
Top achievements
Rank 1
Answers by
Jay
Top achievements
Rank 1
Rosi
Telerik team
Veselin Vasilev
Telerik team
Share this question
or