Search Context functionality provides
context for the search operation. The search context is represented as a simple drop-down giving a choice
to select a context item. This feature improves the performance and usability when searching in large data sets.
Type some letter in the search input while the default "All" item is selected and searching is performed through all
the items of the DataSource.
If you then select some item from the Search Context and type the same letter the
search results in the auto-complete drop down are only those that have the "Key" of the selected item.
The connection between the two DataSources is achieved by the DataContextKeyField property of the SearchBox
that should
be set to the data field which will be used as a context "Key" when the search operation is performed.
The OnClientItemSelected client-side event fires when the user selects an item from the search context dropdown. Its args param provides the following methods:
-
(bool)
get_isDefaultItem()
- returns true if the selected item is the Default item (The search box has a default item called "All" which does not have a value)
-
(Telerik.Web.UI.SearchContextItem)
get_item()
- returns the selected SearchContextItem object
-
(string)
get_text()
- returns the selected SearchContextItem's Text
-
(int)
get_key()
- returns the selected SearchContextItem's Key (otherwise called value)