Error: Combo client instance inside RadToolBar

4 posts, 0 answers
  1. Runat="Server"
    Runat="Server" avatar
    14 posts
    Member since:
    Feb 2010

    Posted 18 Aug 2011 Link to this post


    Please show me how to find combobox with JavaScript inside other rad control! 

    This is my code (not worked!):

    function RadControls_Load(menu, args)
    {
          var combo1 = $find("<%=RadComboBox1.ClientID %>");
          var combo2 = $find("<%=RadComboBox3.ClientID %>");
    }

    ASP.NET:

    <telerik:RadToolBar
                    ID="RadToolBar1"
                    Skin="Windows7"
                    EnableRoundedCorners="true"
                    EnableShadows="true"
                    runat="server"
                    Width="100%"
                    OnClientButtonClicking="BlockEditor_RadToolBar_Top_ClientButtonClicking"
                    OnClientLoad="RadControls_Load" >
                    <Items>
                        <telerik:RadToolBarButton Text="Size" Group="Align" CheckOnClick="true">
                            <ItemTemplate>
                                <telerik:RadComboBox
                                    ID="RadComboBox1"
                                    runat="server"
                                    AllowCustomText="false"
                                    Width="45px">
                                    <Items>
                                        <telerik:RadComboBoxItem runat="server" Text="Size" Value="0" />
                                        <telerik:RadComboBoxItem runat="server" Text="1px" Value="1" />
                                        <telerik:RadComboBoxItem runat="server" Text="2px" Value="2" />
                                        <telerik:RadComboBoxItem runat="server" Text="3px" Value="3" />
                                        <telerik:RadComboBoxItem runat="server" Text="4px" Value="4" />
                                        <telerik:RadComboBoxItem runat="server" Text="5px" Value="5" />
                                    </Items>
                                </telerik:RadComboBox>
                            </ItemTemplate>
                        </telerik:RadToolBarButton>
                        <telerik:RadToolBarButton Text="Style" Group="Align" CheckOnClick="true">
                            <ItemTemplate>
                                <div style="padding-right: 5px;">
                                    <telerik:RadComboBox
                                        ID="RadComboBox3"
                                        runat="server"
                                        AllowCustomText="false"
                                        Width="60px">
                                        <Items>
                                            <telerik:RadComboBoxItem runat="server" Text="Style" Value="Solid" />
                                            <telerik:RadComboBoxItem runat="server" Text="Dashed" Value="Dashed" />
                                            <telerik:RadComboBoxItem runat="server" Text="Dotted" Value="Dotted" />
                                        </Items>
                                    </telerik:RadComboBox>
                                </div>
                            </ItemTemplate>
                        </telerik:RadToolBarButton>
                    </Items>
                </telerik:RadToolBar>
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 18 Aug 2011 Link to this post

    Hello,

    Since the RadComboBox is inside the ItemTemplate, it is not directly available on the page. Try the following method to access it.
    Javascript:
    function RadControls_Load(sender, args)
    {
     var combo= sender._getControl("RadComboBox1"
    }

    Thanks,
    Shinu.
  3. Runat="Server"
    Runat="Server" avatar
    14 posts
    Member since:
    Feb 2010

    Posted 22 Aug 2011 Link to this post

    Hi, 

    Your code is not worked:

    Microsoft JScript runtime error: Object doesn't support property or method '_getControl'

  4. Kalina
    Admin
    Kalina avatar
    918 posts

    Posted 25 Aug 2011 Link to this post

    Hi,

    You can get the RadComboBox client-side object in this way:
    function RadControls_Load(sender, eventArgs) {
     
        var combo = sender.get_items().getItem(0).findControl("RadComboBox1");
        alert(combo.get_text());
        var combo2 = sender.get_items().getItem(1).findControl("RadComboBox3");
        alert(combo2.get_text());
    }

    <telerik:RadToolBar
        ID="RadToolBar1"
        Skin="Windows7"
        EnableRoundedCorners="true"
        EnableShadows="true"
        runat="server"
        Width="100%"
        OnClientButtonClicking="BlockEditor_RadToolBar_Top_ClientButtonClicking"
        OnClientLoad="RadControls_Load" >
        <Items>
            <telerik:RadToolBarButton Text="Size" Group="Align" CheckOnClick="true">
                <ItemTemplate>
                    <telerik:RadComboBox
                        ID="RadComboBox1"
                        runat="server"
                        AllowCustomText="false"
                        Width="45px">
                        <Items>
                            <telerik:RadComboBoxItem runat="server" Text="Size" Value="0" />
                            <telerik:RadComboBoxItem runat="server" Text="1px" Value="1" />
                            <telerik:RadComboBoxItem runat="server" Text="2px" Value="2" />
                            <telerik:RadComboBoxItem runat="server" Text="3px" Value="3" />
                            <telerik:RadComboBoxItem runat="server" Text="4px" Value="4" />
                            <telerik:RadComboBoxItem runat="server" Text="5px" Value="5" />
                        </Items>
                    </telerik:RadComboBox
                </ItemTemplate>
                             
            </telerik:RadToolBarButton>
            <telerik:RadToolBarButton Text="Style" Group="Align" CheckOnClick="true">
                <ItemTemplate>
                    <div style="padding-right: 5px;">
                        <telerik:RadComboBox
                            ID="RadComboBox3"
                            runat="server"
                            AllowCustomText="false"
                            Width="60px">
                            <Items>
                                <telerik:RadComboBoxItem runat="server" Text="Style" Value="Solid" />
                                <telerik:RadComboBoxItem runat="server" Text="Dashed" Value="Dashed" />
                                <telerik:RadComboBoxItem runat="server" Text="Dotted" Value="Dotted" />
                            </Items>
                        </telerik:RadComboBox>
                    </div>
                </ItemTemplate>
            </telerik:RadToolBarButton>
        </Items>
    </telerik:RadToolBar>


    Please find more about RadToolBar client-side API here.

    Kind regards,
    Kalina
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Back to Top