This is a migrated thread and some comments may be shown as answers.

populated using webservice +LoadOnDemand

1 Answer 58 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Łukasz Kuryło
Top achievements
Rank 1
Łukasz Kuryło asked on 23 Mar 2010, 12:44 PM
Hi all.
I have a combobox populated using webservice with LoadOnDemand. My question is how can I select one specific element in combobox when it is populated?
And my second question. The combobox is populated only when I click on the drop down array icon. I would like to populate it when the page is load (or the control is load).How can I do that?

1 Answer, 1 is accepted

Sort by
0
Accepted
Kalina
Telerik team
answered on 26 Mar 2010, 10:41 AM
Hi Łukasz Kuryło,

When Load On Demand feature is enabled, the RadComboBox populates with data after user types in the input area or clicks on the drop-down toggle image.
I am not sure that I understand your requirement, but in case like this you will be not able to predict what values will be populated in order to set a default selected value.

There is an option to set the selected index client side at OnClientItemsRequested event:
function OnClientItemsRequestedHandler(sender, eventArgs)
{
    var combo = $find("<%=RadComboBox1.ClientID %>");
    if (sender.get_items().get_count() > 2) {
        combo.get_items().getItem(1).select();
    }
}

<telerik:RadComboBox ID="RadComboBox1" runat="server" Height="100px" Width="220px"
    ShowMoreResultsBox="true" EnableLoadOnDemand="True" 
    OnClientItemsRequested="OnClientItemsRequestedHandler" >
    <WebServiceSettings Path="LoadItemsWebService.asmx" Method="GetCompanyNames" />
</telerik:RadComboBox>


To fire the web service method and load the items when the page loads you can use the requestItems method of the combobox:

Sys.Application.add_load(function() {
   var combo = $find("<%= RadComboBox1.ClientID %>");
   //invoke the webMethod, e.Text would be empty string
   combo.requestItems("", false);
});


More details you can find at sample page attached.
Please let me know if this was helpful.

Kind regards,
Kalina
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
ComboBox
Asked by
Łukasz Kuryło
Top achievements
Rank 1
Answers by
Kalina
Telerik team
Share this question
or