RadDropDownList OnClientItemsRequesting

5 posts, 0 answers
  1. Bill
    Bill avatar
    3 posts
    Member since:
    Jan 2014

    Posted 09 Jul 2014 Link to this post

    Can I get confirmation that the documentation on RadDropDownList client-side OnClientItemsRequesting event handling is incorrect, as the constructor for the event arguments is coming across as Sys.CancelEventArgs and therefore has no context? The event arguments for the combobox are of type RadComboBoxItemsRequestedEventArgs, which does not have a context, but I see no corresponding class for the DropDownList.

    Is there a workaround that I could use to add a context to the the RadDropDownList OnClientItemsRequesting client-side function?
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 10 Jul 2014 in reply to Bill Link to this post

    Hi Bill,

    The OnClientItemsRequesting event of RadDropDownlist will fire when a request is send to server side to load its items from the web service.  The eventArgs parameter of this event have two methods : get_context and set_cancel.

    The  OnClientItemRequesting event of RadComboBox  will fire when EnableLoadOnDemad is true and need to send a server side request to load more items. The eventArgs parameter of this event have following methods : get_text ,get_context, set_cancel and get_domEvent

    Please have a look into the following help documentation for more information.

    RadDropDownList- OnClientItemsRequesting
    RadComboBox-OnClientItemRequesting

    Let me know if you have any concern.
    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Bill
    Bill avatar
    3 posts
    Member since:
    Jan 2014

    Posted 10 Jul 2014 in reply to Princy Link to this post

    While the eventArgs parameter for the RadDropDownList does have a get_context method, the class does not have a context member or make any mention of the context in the constructor. Attached is a screenshot showing the differing eventArgs for the two controls, with the top showing a watch of the eventArgs when the control is a RadDropDownList and the bottom showing a watch when the control is a RadComboBox.

    Thank you.
  5. Hristo Valyavicharski
    Admin
    Hristo Valyavicharski avatar
    975 posts

    Posted 15 Jul 2014 Link to this post

    Hi Bill,

    To pass value from the OnClientRequesting event try this:

    <telerik:RadDropDownList ID="RadDropDownList2" runat="server" DropDownHeight="200px" DefaultMessage="Select..." OnClientItemsRequesting="OnClientItemsRequesting">
        <WebServiceSettings Method="GetCustomerNames" Path="default.aspx" />
    </telerik:RadDropDownList>

    <script type="text/javascript">
        function OnClientItemsRequesting(sender, args) {
            var context = args.get_context();
            context["test"] = "123";
        }
    </script>

    [WebMethod]
    public static DropDownListData GetCustomerNames(DropDownListContext context)
    {
        var test = context.UserContext["test"];
        ....
    }

    I hope this helps.

    Regards,
    Hristo Valyavicharski
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  6. Bill
    Bill avatar
    3 posts
    Member since:
    Jan 2014

    Posted 15 Jul 2014 in reply to Hristo Valyavicharski Link to this post

    Thank you. After some investigation, I found that as long as using a static WebMethod that is within the page class the context works. However, the context remains undefined when trying to utilize a WCF service (non-static of course). I will check further on how web service settings affect the page rendering and may move web methods into my page if no other option exists.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017