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

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

5 Answers 82 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 03 Sep 2015, 02:58 PM

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.

 

5 Answers, 1 is accepted

Sort by
0
John
Top achievements
Rank 1
answered on 04 Sep 2015, 11:05 AM

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>

0
Nencho
Telerik team
answered on 08 Sep 2015, 10:07 AM
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
0
John
Top achievements
Rank 1
answered on 09 Sep 2015, 09:01 AM

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.

0
Nencho
Telerik team
answered on 14 Sep 2015, 08:10 AM
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
0
John
Top achievements
Rank 1
answered on 17 Sep 2015, 08:59 AM

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

Thanks anyway. 

Tags
ComboBox
Asked by
John
Top achievements
Rank 1
Answers by
John
Top achievements
Rank 1
Nencho
Telerik team
Share this question
or