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

Load items asynchronously

4 Answers 172 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Quantesys IT
Top achievements
Rank 1
Quantesys IT asked on 08 Apr 2011, 02:00 PM
Hello,

I have a UserControl with different fields and a RadComboBox. I want to reduze the time that the user needs to wait (actually the RadComboBox is populated on server-side and it takes a lot of time).

The content of the RadComboBox is not required immediatly; the user needs to fill some fields before. I want to use a WebService or HttpHandler to fill the RadComboBox asynchronously and make it completly "invisible" for the user.

I found some solutions to load the items using a WebService/WCF but the request is sent only when the user try to display the RadComboBox's content (LoadOnDemand)!

Is there a solution to call the WebService automatically after the page load without an interaction of the user?

Thank you for your help.

4 Answers, 1 is accepted

Sort by
0
Kalina
Telerik team
answered on 08 Apr 2011, 03:18 PM
Hi Quantesys IT,

Let me suggest you call the web service and perform a request for items at OnClientLoad event of the RadComboBox:
function OnClientLoad(sender)
{
    sender.requestItems("", false);
}

All the best,
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
0
Quantesys IT
Top achievements
Rank 1
answered on 20 Apr 2011, 08:11 AM
Thank you for your help, it works perfectly!

But now I have another problem :-(

My ComboBox needs to fire a PostBack on index changed and I need to get some attributes from server-side. Before the use of WebService it was easy to do the job because of SelectedItem object.

Here is a part of my WebService:
RadComboBoxData result = new RadComboBoxData();
List<RadComboBoxItemData> items = new List<RadComboBoxItemData>();
 
...
 
RadComboBoxItemData item = new RadComboBoxItemData();
item.Text = myObject.Name;
item.Value = myObject.Id.ToString();
item.Attributes.Add("FirstAttribute", myObject.FirstAttribute);
item.Attributes.Add("SecondAttribute", myObject.SecondAttribute);
items.Add(item);
 
result.Items = items.ToArray();
 
return result;

How can I get the value of these additional attributes when the OnSelectedIndexChanged event is fired?

Thank you for your help
0
Accepted
Kalina
Telerik team
answered on 21 Apr 2011, 10:54 AM
Hello,

RadComboBox items loaded via Load On Demand are not accessible at server-side - please find more details about this issue at this help article.
Let me suggest you add a HiddenField at your page and store the value, text and/or attribute of the selected RadComboBoxItem in it handling the OnClientSelectedIndexChanged event in this manner:
<script type="text/javascript">
    var hiddenField;
     
    function pageLoad() {                
        hiddenField = document.getElementById("<%=selectedValues.ClientID %>"
    }
    
    function OnClientSelectedIndexChangedHandler(sender, eventArgs) {
     
        hiddenField.value = sender.get_selectedItem().get_value();
       
    }
 
</script>

<asp:HiddenField ID="selectedValues" runat="server" EnableViewState="true" />
 
<telerik:RadComboBox ID="RadComboBox1" runat="server"
    OnClientSelectedIndexChanged="OnClientSelectedIndexChangedHandler"  ... >

Then you can easily obtain the value of the HiddenField at server-side:
string parameters = selectedValues.Value;


All the best,
Kalina
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
Quantesys IT
Top achievements
Rank 1
answered on 26 Apr 2011, 12:49 PM
Thank your for your help, it works great!
Tags
ComboBox
Asked by
Quantesys IT
Top achievements
Rank 1
Answers by
Kalina
Telerik team
Quantesys IT
Top achievements
Rank 1
Share this question
or