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

How to attach to OnClientItemsRequested in JS?

1 Answer 73 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Branimir Giurov
Top achievements
Rank 1
Branimir Giurov asked on 24 Oct 2013, 09:32 AM
Hi,

I have the following script rendering in my aspx:


Sys.Application.add_load(function () {
    var target = $find('{0}');
 
    alert(target.get_id());
    //finds it
 
    $addHandler(target, "OnClientItemsRequested", function (sender, e) { alert('OnClientItemsRequested'); });
    $addHandler(target, "onclientItemsRequested", function (sender, e) { alert('onclientItemsRequested'); });
    $addHandler(target, "clientItemsRequested", function (sender, e) { alert('clientItemsRequested'); });
    $addHandler(target, "clientitemsrequested", function (sender, e) { alert('clientitemsrequested'); });
    $addHandler(target, "onclientitemsrequested", function (sender, e) { alert('onclientitemsrequested'); });
 
    //none fires
});

The alert showing server id fires, nothing else happens after using the auto-populate, while the same event works when I configure the event-handler in combobox's properties.

My problem is none of the subscriptions works, so is there a way to attach an event-handler function for OnClientItemsRequested in JS?

Thx in advance,
Branimir Giurov

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 28 Oct 2013, 01:07 PM
Hi Branimir,

To attach the OnClientItemsRequested client event of the RadComboBox from JavaScript, you must use the add_itemsRequested method as shown in the following sample code.

ASPX:
<telerik:RadComboBox ID="RadComboBox1" runat="server" OnClientLoad="OnClientLoad"
    EnableLoadOnDemand="true">
</telerik:RadComboBox>

JavaScript:
<script type="text/javascript">
    function OnClientLoad(sender, args) {
        sender.add_itemsRequested(OnClientItemsRequested);
    }
 
    function OnClientItemsRequested(sender, args) {
        //Your Code
    }
</script>

Thanks,
Shinu.
Tags
ComboBox
Asked by
Branimir Giurov
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or