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

RadDropDownList OnClientItemsRequesting

4 Answers 40 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Bill
Top achievements
Rank 1
Bill asked on 09 Jul 2014, 01:24 PM
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?

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 10 Jul 2014, 05:32 AM
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.
0
Bill
Top achievements
Rank 1
answered on 10 Jul 2014, 12:45 PM
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.
0
Hristo Valyavicharski
Telerik team
answered on 15 Jul 2014, 12:01 PM
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.

 
0
Bill
Top achievements
Rank 1
answered on 15 Jul 2014, 04:00 PM
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.
Tags
DropDownList
Asked by
Bill
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Bill
Top achievements
Rank 1
Hristo Valyavicharski
Telerik team
Share this question
or