Telerik RadComboBox exposes rich and flexible client-side API which provides a set of objects, properties, methods and events.
Getting the client-side Telerik RadComboBox instance
You can get the client-side object instance of Telerik RadComboBox using its ClientID, e.g. for combobox instance with ID="RadComboBox1":
<radcb:RadComboBox runat="server" ID="RadComboBox1" ... />
You can get the instance using the following JavaScript:
<script language="javascript">
var RadComboBox1 = <%= RadComboBox1.ClientID %>;
var comboText = RadComboBox1.GetText();
alert(comboText);
</script>
RadComboBox object
Properties
Once you get the client-side object instance, you can use various properties / methods.
|
Property |
Description |
|
ID |
The server ID of the combobox (string). |
|
ClientID |
The client ID of the combobox (string). |
|
DropDownID |
The ID of the dropdown div (string). |
|
InputID |
The ID of the input box (string). |
|
ImageID |
The ID of the combo box dropdown image (string). |
|
MoreResultsBoxID |
The ID of the More Results Box (string). |
|
MoreResultsBoxMessageID |
The ID of the More Result Box Message (string). |
|
DropDownVisible |
If the dropdown has been opened (bool). |
|
ItemRequestTimeout |
The delay in ms before items are requested (int). |
|
Overlay |
If overlay is enabled (bool). |
|
AutoPostBack |
If AutoPostBack is enabled (bool). |
|
Enabled |
Determines whether the combobox is enabled or not. |
|
SelectedItem |
The currently selected item in the combobox. |
|
SelectedIndex |
The index of currently selected item in the combobox. |
Collections
|
Collection |
Description |
|
Items |
A javascript array containing all RadComboBoxItem client instances. |
Methods
|
Method |
Description |
|
SetText(text) |
Sets the combobox text to the parameter of the function, e.g. comboInstance.SetText("New Text") |
|
GetText() |
Returns the current combo text. |
|
ShowDropDown() |
Opens the dropdown. |
|
HideDropDown() |
Closes the dropdown. |
|
ToggleDropDown() |
Toggles the dropdown. |
|
RequestItems(text, more) |
Initiates callback request (ItemsRequested server events is fired) with the specified text. The second bool parameter instructs the combo to append the new items (true) or clear items (false). |
|
SetValue(text) |
Sets the combobox value to the parameter of the function, e.g. comboInstance.SetValue("New Text") |
|
GetValue() |
Returns the current combo value. |
|
Enable() / Disable() |
Enables/Disables the combobox. |
|
FindItemByValue / FindItemByText |
Return CombItem instance which matches this value/text. |
|
ClearItems() |
Clear all items in the combobox. |
RadComboBoxItem object
Properties
|
Property |
Description |
|
ComboBox |
The instance of the combobox parent (object). |
|
ClientID |
The ClientID of the item (string). |
|
Highlighted |
If the item is currently highlighted (bool). |
|
Index |
Index of the item in the Items collection (int). |
|
Enabled |
If the item is current. |
|
Text |
The text of the item. |
|
Value |
The value of the item. |
Collections
|
Collection |
Description |
|
Attributes |
A collection of custom attributes (as passed from the server-side Attributes collection). |
Here's how you can get the ImagePath custom attribute of the first item in a combobox:
|
Copy Code |
|
<script language="javascript"> var RadComboBox1 = <%= RadComboBox1.ClientID %>; alert(RadComboBox1.Items[0].Attributes.ImagePath) </script> |
Methods
|
Method |
Description |
|
Highlight() |
Highlights the item. |
|
UnHighlight() |
Unhighlights the item. |
|
Select() |
Selects the item. |
Below is an example of using the Select() method. The other two methods share a similar logic.
|
Copy Code |
|
<script language="javascript"> function SelectItem() { var comboInstance = <%= combo.ClientID%>; var comboItem = comboInstance.FindItemByValue(1);
if (comboItem != null) comboItem.Select(); } </script> |
See Also