1

I'm new to telerik components, and I have a strange problem.

I'm populating a RadComboBox through JS by calling requestItems based on another combobox selection.

The data populates correctly, but visually only when I click on the combobox a second time does the list appear.

In the source, the data exists, but all the rcbItem have display none , and rcbScroll rcbWidth as a height of 0px. Only on the second click does the list appear.

Here's the JS code:

//global variables for the countries and cities comboboxes
var ouCombo;
var dsCombo;
var searchBox;

    function pageLoad() {
        ouCombo = $find("<%= UnitRadComboBox.ClientID %>");
        dsCombo = $find("<%= ServiceRadComboBox.ClientID %>");
        searchBox = $find("<%= SearchRadTextBox.ClientID %>")
    }

    function loadDepartments(sender, eventArgs) {
        var item = eventArgs.get_item();
        dsCombo.set_text("A carregar...");
        // if a continent is selected
        if (item.get_index() > 0) {
            // this will fire the ItemsRequested event of the 
            // combobox passing the ID as a parameter 
            dsCombo.requestItems(item.get_value(), false);
        }
        else {
            // the - empty - item was chosen
            dsCombo.set_text(" ");
            dsCombo.clearItems();
        }
    }

    function ItemsLoaded(sender, eventArgs) {
        if (sender.get_items().get_count() > 0) {
            // pre-select the first item
            sender.set_text("Escolha uma opçao");
            //sender.get_items().getItem(0).highlight();
            //sender.showDropDown();
            var radInput = $find("<%= SearchRadTextBox.ClientID %>");
            radInput.focus();
        }
    }

Here's the markup

 <telerik:RadComboBox ID="UnitRadComboBox" runat="server" OnItemsRequested="UnitRadComboBox_ItemsRequested1"
            HighlightTemplatedItems="true" EnableLoadOnDemand="true" OnClientSelectedIndexChanging="loadDepartments"
            OnClientItemsRequested="ItemsLoaded" LoadingMessage="A carregar..." Skin="Default">
            <CollapseAnimation Type="OutQuint" Duration="200" />
</telerik:RadComboBox>

<telerik:RadComboBox ID="ServiceRadComboBox" runat="server" HighlightTemplatedItems="true"
            EnableLoadOnDemand="true" Filter="StartsWith" OnItemsRequested="ServiceRadComboBox_ItemsRequested"
            OnClientItemsRequested="ItemsLoaded" Width="250px" LoadingMessage="A carregar...">
            <CollapseAnimation Type="OutQuint" Duration="200" />
</telerik:RadComboBox>
Ricardo Gomes
  • 1,268
  • 2
  • 15
  • 35

1 Answers1

0

Delete: sender.set_text("Escolha uma opçao"); and see if that works.

Giovanni Di Toro
  • 797
  • 1
  • 14
  • 34