Get a treeview instance with JS

2 posts, 1 answers
  1. Web Services
    Web Services avatar
    243 posts
    Member since:
    Apr 2008

    Posted 25 Sep 2009 Link to this post

    I need to get the equivalent to $find('<%=RadTreeView1.ClientID %>'); in JavaScript. The problem is my treeview is nested within a radpanelbar. Here is the code I have so far but it is not working.

                scheduler = $find('<%=RadScheduler1.ClientID %>');
                panelBar = $find('<%=RadPanelBar1.ClientID %>');
                item = panelBar.findItemByText("Events");
                treeview = item.findControl('<%=RadTreeView1.ClientID %>');

    Here is the aspx of the panel bar.
    <telerik:RadPanelBar ID="RadPanelBar1" runat="server" Skin="Web20" ExpandMode="SingleExpandedItem"
            AllowCollapseAllItems="false" Width="220px" BorderStyle="None" OnClientItemClicked="itemClicked"
                Height="500px">
                <CollapseAnimation Type="None" Duration="100"></CollapseAnimation>
                <Items>
                    <telerik:RadPanelItem runat="server" Text="Events" Font-Bold="true" Font-Size="Medium"
                        Expanded="true">
                        <Items>
                            <telerik:RadPanelItem runat="server">
                                <ItemTemplate>
                                    <telerik:RadTreeView ID="RadTreeView1" runat="server" Skin="Web20" CssClass="leftPanelContent"
                                        CheckBoxes="true" OnClientNodeChecking="OnClientNodeChecked" OnClientNodeClicking="OnClientNodeClicking">
                                    </telerik:RadTreeView>
                                </ItemTemplate>
                            </telerik:RadPanelItem>
                        </Items>
                    </telerik:RadPanelItem>

    Thanks,


  2. Answer
    Yana
    Admin
    Yana avatar
    4203 posts
    Member since:
    Sep 2012

    Posted 26 Sep 2009 Link to this post

    Hello,

    Actually the treeview is not in the template of the "Events" item, but in its first child's template, so the code should be like this:

    var panelBar = $find('<%=RadPanelBar1.ClientID %>'); 
    var item = panelBar.findItemByText("Events"); 
    var treeview = item.get_items().getItem(0).findControl("RadTreeView1"); 

    Kind regards,
    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