RadComboBox populated by Web Service. DataBind doesn't populate the ComboBox!

6 posts, 0 answers
  1. John
    John avatar
    31 posts
    Member since:
    May 2014

    Posted 03 Sep 2015 Link to this post

    Hello,

    I am in the process of migrating some combo boxes that used to be data source driven to be populated from a web service. I am facing a scenario where I need to force the combo box to load by calling ComboBox.DataBind() in the code behind. However, following the call the ComboBox contains no data!

    I have tried searching for a solution and I have referred to the documentation but I can't find anything that works. I should mention that the combo box is populated if the user interacts with it so it is configured correctly, the web service is returning data and so on.

    I have tried experimenting with different values for EnableLoadOnDemand and EnableAutomaticLoadOnDemand but no luck!

    Any help would be appreciated, so thanks in advance.

    John.

     

  2. John
    John avatar
    31 posts
    Member since:
    May 2014

    Posted 04 Sep 2015 Link to this post

    By the way, I have tried calling the requestItems method on the RadCombo box in the OnClientLoad() handler. However, there are no items. But, if I call combo.showDropDown() instead then the items appear.

     <script type="text/javascript">

        function OnClientLoadHandler(sender) {
            var combo = sender;

            combo.requestItems();

            var items = combo.get_items();

            for (var i = 0; i < items.get_count() ; i++) {
                console.log(items.getItem(i).get_text());
            }
        }
    </script>

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Nencho
    Admin
    Nencho avatar
    1457 posts

    Posted 08 Sep 2015 Link to this post

    Hello John,

    In order to trigger the requestItems event you should pass an empty string as a paramenter. Please consider the following implementation:

    <script type="text/javascript">
     
        function OnClientLoadHandler(sender) {
            var combo = sender;
     
            combo.requestItems("");
     
            ......................
        }
    </script>


    Regards,
    Nencho
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
  5. John
    John avatar
    31 posts
    Member since:
    May 2014

    Posted 09 Sep 2015 in reply to Nencho Link to this post

    Hi Nencho,

    Thanks for your reply. We have tried what you have suggested, that is making the following call.

    combo.requestItems("");

    It seems that this will force the combo box to reload fully. However, the items are not available at the appropriate point in the page life cycle for us. So,​ it doesn't really solve our problem because what we need is to, as per my original post, to be able to 

    "force the combo box to load by calling ComboBox.DataBind() in the code behind."

    Is there any way that this can be achieved? Please let me know if you need any additional information.

    Thanks,

    John.

  6. Nencho
    Admin
    Nencho avatar
    1457 posts

    Posted 14 Sep 2015 Link to this post

    Hello John,

    I am afraid that the DataBind method will push the control to request the data, only if a Declarative DataSource binding approach is used for population with data. In addition, if the LoadOnDemand mechanism is used - the Items are not accessible on the server, as specified in the following documentation article:

    http://docs.telerik.com/devtools/aspnet-ajax/controls/combobox/troubleshooting/radcombobox-items-are-not-accessible-on-the-server-side-when-loading-them-on-demand


    Regards,
    Nencho
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
  7. John
    John avatar
    31 posts
    Member since:
    May 2014

    Posted 17 Sep 2015 in reply to Nencho Link to this post

    OK. That's a pity. We will have to work around this somehow.

    Thanks anyway. 

Back to Top
UI for ASP.NET Ajax is Ready for VS 2017