Load items asynchronously

5 posts, 1 answers
  1. Quantesys IT
    Quantesys IT avatar
    21 posts
    Member since:
    Feb 2009

    Posted 08 Apr 2011 Link to this post

    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.
  2. Kalina
    Admin
    Kalina avatar
    918 posts

    Posted 08 Apr 2011 Link to this post

    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
  3. Quantesys IT
    Quantesys IT avatar
    21 posts
    Member since:
    Feb 2009

    Posted 20 Apr 2011 Link to this post

    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
  4. Answer
    Kalina
    Admin
    Kalina avatar
    918 posts

    Posted 21 Apr 2011 Link to this post

    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.

  5. Quantesys IT
    Quantesys IT avatar
    21 posts
    Member since:
    Feb 2009

    Posted 26 Apr 2011 Link to this post

    Thank your for your help, it works great!
Back to Top