Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET > Combobox > select value using javascript of a loadable on demand rad combo box
RadControls for ASP.NET are no longer supported (see this page for reference). In case you have inquiries about the Telerik ASP.NET AJAX controls, post them in the pertinent ASP.NET AJAX forums.

Answered select value using javascript of a loadable on demand rad combo box

Feed from this thread
  • Gabriel avatar

    Posted on Apr 27, 2011 (permalink)

    I have a grid wich shows all customers in my company. When I click on a customer a modal panel shows up with lots of controls. I need to set the value for each of those controls via javascript. For this purpose I am using a PageMethod call.

    I've been able of setting up the value of all of them, except for a RadComboBox with LoadOnDemand activated, this combo box loads items thanks to a webService. I can write some text on the combo box and the webService will take the context, analyze it and filter the items of the combo box according to the filter.

    So far everything is good, the problem is:
    When I try to search for an Item on my LoadableOnDemand RadComboBox, I find nothing, this is obvious, because it doesn't have any item yet.

    so, how can I select an Item which has not been loaded yet?
    is there a way of forcing loading of data of the RadComboBox?
    should I create an item and add it manually to the RadComboBox?

    in advance, many thanks

  • Answer Dimitar Terziev Dimitar Terziev admin's avatar

    Posted on May 2, 2011 (permalink)

    Hi Gabriel,

    In order to load data into the RadComboBox when this modal panel shows, subscribe on the OnClientLoad client-side event and initiate a request for items using the requestItems method of the RadComboBox.

    On order to preselect the first item once data is loaded you could subscribe on the OnClientItemsRequested client-side event and use the following implementation:
    function OnClientItemsRequested(sender, args){
     
        sender.get_items().getItem(0).select();
    }

    I've prepared a sample page based on the above explained approach.

    Regards,
    Dimitar Terziev
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

    Attached files

  • Gabriel avatar

    Posted on May 2, 2011 (permalink)

    Thank you very much!

    I finally did the following:
    1. I created the event OnClientItemsRequested in the comboBox
    2. I created a hidden field to control the execution of code in event OnClientItemsRequested 
    3. I modified the function which fills the modal with data

    The Event:
    function OnClientItemsRequested_loadable_on_demand_cbo(sender, args)
    {
    if ($("#hid_control_data_loading").val() == "true") {
    sender.get_items().getItem(0).select();
    $(
    "#hid_control_data_loading").val("false")
    }
    }


    The Hidden:
    <input type="hidden" id="hid_control_data_loading" />


    The FillingModal Function:

    var rcb = $find('cbo_loadable_on_demand');
    var context = "1154";
    rcb.requestItems(String.format(
    "{0}", context), false);
    $("#hid_control_data_loading").val("true");

    Thank you very much ^^

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET > Combobox > select value using javascript of a loadable on demand rad combo box