This is a migrated thread and some comments may be shown as answers.
initiate load on demand
2 Answers 11 Views
This is a migrated thread and some comments may be shown as answers.
Merin
Top achievements
Rank 1
Merin asked on 26 Aug 2013, 08:30 AM
Hi

I have a radcombo with load on demand enabled. But at some point I want to load items on a button click. So can I initiate a load on demand from code?

Merin

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 1
answered on 29 Aug 2013, 05:36 AM
Hi Merin,

You can use the requestItems client method to initiate a load-on-demand callback request with the specified text, causing the ItemsRequested server event to fire or a request to be sent to a web service. The second bool parameter instructs the RadComboBox to append the new items (True) or clear items (False). Please check the following code snippet.

JavaScript:
<script type="text/javascript">
    function OnClientClicked(sender, args) {
        var radcombobox = $find("<%= RadComboBox1.ClientID %>");
        radcombobox.requestItems("Item1", true);
    }
</script>

Thanks,
Shinu.
0
Hristo Valyavicharski
Telerik team
answered on 29 Aug 2013, 08:33 AM
Hi Merin,

When use LoadOnDemand items are not loaded initially. The ItemsRequested server event will be fired if the drop down is opened or if any text is typed in the combo's input. Usually in this event combo is populated  with data.  From code you could initially load items as call combo's requestItems() method in the pageLoad event. For example:
<script type="text/javascript">
    function pageLoad() {
        var combo = $find('RadComboBox1');
        combo.requestItems();
    }
</script>
<div>
    <telerik:RadComboBox
        ID="RadComboBox1"
        runat="server"
        Filter="Contains"
        OnItemsRequested="RadComboBox1_ItemsRequested"
        EnableLoadOnDemand="true">
    </telerik:RadComboBox>
</div>


Regards,
Hristo Valyavicharski
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Asked by
Merin
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Hristo Valyavicharski
Telerik team
Share this question
or