How to attach to OnClientItemsRequested in JS?

2 posts, 0 answers
  1. Branimir Giurov
    Branimir Giurov avatar
    2 posts
    Member since:
    Aug 2007

    Posted 24 Oct 2013 Link to this post

    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
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 28 Oct 2013 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top