Telerik RadComboBox API Error

I'm having a problem using Telerik's javascript API RadComboBox. And no, I have no way to switch from Telerik to jQuery or to another framework. Suffice it to say that I have almost no hair left on my head: P

In a nutshell, I want to capture the selected index of one RadComboBox and update another RadComboBox to this index. For example. selecting a value in the first RCB automatically updates the second on the client side. My problem is that I cannot find a way to set the index in the second RCB, although the docs say there is an easy way to do this .. (you heard that one is in front of the right one :)

I followed the API docs on this page ( telerik docs ) and also used the javascript debugger in IE8 and the excellent FireBug in Firefox. I am using the build version of Telerik.Web.UI 2009.2.826.20

I do not need a complete source for a solution, but a push in the right direction would be greatly appreciated! :)

Here is an example of the code I prepared together:


    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server" />

    <script type="text/javascript" language="javascript">
        function masterChanged(item)
        {
            var detailCB = <%= DetailCB.ClientID %>;

            var index = item.get_selectedIndex();
            detailCB.SetSelected(index);             //method does not exist, but should according to the docs..

        }
    </script>

    <div>
        <telerik:RadComboBox ID="MasterCB" runat="server" OnClientSelectedIndexChanged="masterChanged">
            <Items>
                <telerik:RadComboBoxItem Text="One" Value="1" runat="server" />                
                <telerik:RadComboBoxItem Text="Two" Value="2" runat="server" />
                <telerik:RadComboBoxItem Text="Three" Value="3" runat="server" />
            </Items>
        </telerik:RadComboBox>
    </div>

    <div>
        <telerik:RadComboBox ID="DetailCB" runat="server">
            <Items>
                <telerik:RadComboBoxItem Text="One" Value="1" runat="server" />                
                <telerik:RadComboBoxItem Text="Two" Value="2" runat="server" />
                <telerik:RadComboBoxItem Text="Three" Value="3" runat="server" />
            </Items>
        </telerik:RadComboBox>
    </div>
</form>

I do not need a complete source for a solution, but a blow in the right direction would be greatly appreciated! :)

+3
source share
3 answers

Many thanks to Veselin Vasilev and stefpet for their contribution. After too many hours of debugging js and cups of coffee, I got this to work with IE8 and FF3.5.

javascript RadComboBoxes ( OnClientSelectedIndexChanged):

    function masterChanged(sender, e)
    {
        var detailCB = $find("<%= DetailCB.ClientID %>");

        var item = e.get_item();
        var index = item.get_index();                //get selectedIndex in master
        var allDetailItems = detailCB.get_items();
        var itemAtIndex = allDetailItems.getItem(index);  //get item in detailCB
        itemAtIndex.select();
    }

, , , . , , , , .

+3

API "" RadComboBox, ASP.NET AJAX. :

function masterChanged(item)
{
    var detailCB = $find("<%= DetailCB.ClientID %>");

    var index = item.get_selectedIndex();
    detailCB.set_selectedIndex(index);            
}

: http://www.telerik.com/help/aspnet-ajax/combo_clientsidebasics.html

+3

Telerik, , , , , , selected true.

-2
source

Source: https://habr.com/ru/post/1724491/


All Articles