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

Custom data in RadComboBoxContext

2 Answers 172 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Simon
Top achievements
Rank 2
Simon asked on 06 Oct 2010, 11:04 AM
Hi,

I want to use load-on-demand with a web service to filter the results of my combo box as the user types in it. I have looked at the example here:
http://www.telerik.com/help/aspnet-ajax/combo_loadondemandwebservice.html

The example works fine if I only want to filter the results according to the text the user has typed. However I also need to be able to access other criteria from the user session with which to filter the data. Specifically, I need to know who the user is logged in as, so I can pre-filter the results based on which ones they are allowed to see. Their userid is held in Session state and I need to be able to retrieve it in order to narrow the results further.

The RadComboBoxContext has no property which allows me to get at the Session state, so how can I do so from within the web service method? I have seen posts elsewhere which suggest adding custom data to the context, but how is this done? How do I get my Session state data into the context in the first place?

Thanks,
S.

2 Answers, 1 is accepted

Sort by
0
Simon
Top achievements
Rank 2
answered on 06 Oct 2010, 03:59 PM
I've sorted it.

You have to use the OnClientItemsRequesting attribute of the RadComboBox to specify a client function, which creates an appropriate dictionary item in the context object passed to it. The client function is then inserted into the page at runtime using ClientScript.RegisterClientScriptBlock, enabling you to hardcode whatever session variables you need directly into the client function. The web service method can then investigate the context object and find the item created by the client function.

0
Otto Neff
Top achievements
Rank 2
answered on 09 Jan 2014, 09:04 AM
Hi Simon,

thanks for this nice hint. Works like a charm....

Example for addtional ClientID in RadComboBoxContext

box.OnClientItemsRequesting = "function(sender,args){args.get_context()['ClientID'] = '" + box.ClientID + "';}";

Cheers Otto.
Tags
ComboBox
Asked by
Simon
Top achievements
Rank 2
Answers by
Simon
Top achievements
Rank 2
Otto Neff
Top achievements
Rank 2
Share this question
or