You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The **OnClientItemSelected** is a Client-Side event that is triggered when an item from the SearchBox dropdown (SearchContext) is clicked.
13
+
14
+
The event handler receives two parameters:
15
+
16
+
1. The instance of (`Telerik.Web.UI.SearchContext`) firing the event, the [SearchContext object]({%slug searchbox/client-side-programming/searchcontext-object%}).
17
+
18
+
2. The event arguments that contains the following methods:
19
+
20
+
-`(Telerik.Web.UI.SearchContextItem)`**get_item()** - returns the [SearchContextItem object]({%slug searchbox/client-side-programming/searchcontextitem-object%}).
21
+
-`(bool)`**get_isDefaultItem()** - returns `true` if the [Default ("All")]({%slug searchbox/search-context/overview%}#summary-of-features-supported-by-radsearchboxs-search-context) item was selected
22
+
-`(string)`**get_text()** - returns the selected SearchContext Item's Text
23
+
-`(string/int)`**get_key()** - returns the selected SearchContext Item's Key (commonly known as the value)
Copy file name to clipboardExpand all lines: controls/searchbox/search-context/overview.md
+24-35
Original file line number
Diff line number
Diff line change
@@ -13,7 +13,7 @@ position: 0
13
13
**Search Context functionality** was added from Q2 2013 in order to provide 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.
14
14
15
15
SearchBox's Search Context behaves as a standard DropDownList control with single selection. It has Items which are accessible server as well as client side.
@@ -30,52 +30,41 @@ SearchBox's Search Context behaves as a standard DropDownList control with singl
30
30
````
31
31
32
32
33
+
## Supported Features
33
34
34
-
## Summary of features supported by RadSearchBox's Search Context
35
+
Summary of features supported by RadSearchBox's Search Context
35
36
36
-
***Data Binding**
37
+
-**Data Binding** - binding SearchContext to a data source
38
+
-**Declarative items** – SeachContextItems could be defined in the markup or added dynamically from code-behind.
39
+
-[**Server-side**]({%slug searchbox/search-context/data-binding/server-side-binding%}) – server API for setting data source using DataSourceID/DataSource properties.
40
+
-[**Client-side**]({%slug searchbox/search-context/data-binding/client-side-binding%}) – client API for population through Web services and integration with RadODataDataSource control.
41
+
-**Default "All" Item** – Search Context renders an item which when selected won't provide context for the search operation. This item could be omitted if the **ShowDefaultItem** property is set to False (it's True by default).
42
+
-**Loading Message** - When the default item is not shown and the SearchContext's is populate from a web service or bound to the RadODataDataSource control, a message is shown in the input of the Search Context while the items are being loaded and initialized. Once loaded the message is removed and the first item in the list is selected.
43
+
-**Localization** - both the text of the default items as well as the loading message could be localized through the **Localization-DefaultItemText** and **Localization-LoadingItemsMessage** properties.
44
+
-[**Keyboard Support**]({%slug searchbox/accessibility-and-internationalization/keyboard-support%}) - Search Context has a fully functional keyboard support, which is available once the control is focused. In order to be able to focus the Search Context the **TabIndex** property should be set.
37
45
38
-
* Declarative items – SeachContextItems could be defined in the markup or added dynamically from code-behind.
39
46
40
-
*[Server-side]({%slug searchbox/search-context/data-binding/server-side-binding%}) – server API for setting data source using DataSourceID/DataSource properties.
41
-
42
-
*[Client-side ]({%slug searchbox/search-context/data-binding/client-side-binding%}) – client API for population through Web services and integration with RadODataDataSource control.
43
-
44
-
***Default "All" Item** – Search Context renders an item which when selected won't provide context for the search operation. This item could be omitted if the **ShowDefaultItem** property is set to False (it's True by default).
45
-
46
-
***Loading Message** - When the default item is not shown and the SearchContext's is populate from a web service or bound to the RadODataDataSource control, a message is shown in the input of the Search Context while the items are being loaded and initialized. Once loaded the message is removed and the first item in the list is selected.
47
-
48
-
***Localization** - both the text of the default items as well as the loading message could be localized through the **Localization-DefaultItemText** and **Localization-LoadingItemsMessage** properties.
49
-
50
-
*[Keyboard Support]({%slug searchbox/accessibility-and-internationalization/keyboard-support%}) - Search Context has a fully functional keyboard support, which is available once the control is focused. In order to be able to focus the Search Context the **TabIndex** property should be set.
51
-
52
-
***ItemDataBoud** - server-side event fired for every SearchContextItem create as a result of a binding to a data source.
53
-
54
-
***ClientItemDataBoud** - client-side event fired for every SearchContextItem create as a result of a binding to a RadODataDataSource control.
55
-
56
-
## Databinding Properties and Methods
47
+
## Data Binding
57
48
58
49
When binding Search Context to a particular Data Source you will need to use the following properties.
59
50
60
-
***DataSource** property - set to an instance of your data source. This is mandatory when binding SearchContext at runtime.
61
-
62
-
***DataSourceID** property - set to the ID of your data source. This is mandatory when binding SearchContext declaratively.
63
-
64
-
***DataTextField** property - field name from the data source bound to the SearchContextItem's **Text** property.
65
-
66
-
***DataKeyField** property - field name from the data source bound to the SearchContextItem's **Key** property.
67
-
68
-
***DataModelID** property is used to set the ModelID when binding SearchContext to RadODataDataSource control.
51
+
-**DataSource** - set to an instance of your data source. This is mandatory when binding SearchContext at runtime.
52
+
-**DataSourceID** - set to the ID of a DataSource Control (SqlDataSource, ObjectDataSource, etc). This is mandatory when binding SearchContext declaratively.
53
+
-**DataTextField** - set the field name from the data source bound to the SearchContextItem's **Text** property.
54
+
-**DataKeyField** - set the field name from the data source bound to the SearchContextItem's **Key** property.
55
+
-**DataModelID** - set the ModelID when binding SearchContext to RadODataDataSource control.
69
56
70
-
## Summary of SearchContextItem's properties
57
+
Once the data binding is configured, you will be able to access the values through the SearchContext Item object. For a list properties and methods, check out the [SearchContextItem Object]({%slug searchbox/client-side-programming/searchcontextitem-object%}) article.
71
58
72
-
***Text** – property defining the text of the SearchContextItem.
59
+
## Events
73
60
74
-
***Key** – this property defines the value which is used as a context when the search operation is performed and the SearchBox is bound to a data source control or RadODataDataSouce components.
61
+
-**Server-Side**:
62
+
-[ItemDataBound]({%slug searchbox/search-context/events/onitemdatabound%}) - server-side event fired for every SearchContextItem create as a result of a binding to a data source.
75
63
76
-
***ImageUrl** – this property accepts a path to a physical image.
64
+
-**Client-Side**:
65
+
-[ClientItemDataBound]({%slug searchbox/search-context/events/onclientitemdatabound%}) - client-side event fired for every SearchContextItem create as a result of a binding to a RadODataDataSource control.
66
+
-[ClientItemSelected]({%slug searchbox/search-context/events/onclientitemselected%}) - client-side event fired when a SearchContext item is selected.
77
67
78
-
***Selected** – property defining the selected state of the item (Search Context could have only one selected item at a time).
0 commit comments