New to Telerik UI for ASP.NET AJAXStart a free 30-day trial

RadComboBox Object

This article explains about the methods of the RadComboBox client-side object. The RadComboBox client API allows for complete control over the client object, giving the developer the opportunity to set the behavior of the control depending on the scenario.

Telerik has removed the tlrkComboBoxes array from the RadComboBox object. You should use Telerik.Web.UI.RadComboBox.ComboBoxes instead - which you can use to obtain an array containing all the client-side RadComboBox instances.

The following table lists the most important methods of the client-side RadComboBox object:

 

NameParametersReturn TypeDescription
trackChangesnonenoneStarts tracking changes made to RadComboBox that will be preserved over postbacks. See Example 1.
commitChangesnonenoneWrites the changes to RadComboBox that were made since a previous call to trackChanges , so that they are preserved over postbacks. Client-side changes are available on the server after postback. You can use the ClientChanges property to access them. See Example 1.
set_text(string text)noneSets the text of the input field to the value of the specified parameter. See Example 2.
get_textnonestringGets the text of the input field.
get_checkedItemsnonearrayGets an array of the checked RadComboBoxItem objects.
get_lastWordnonestringGets the word after the last separator in the text of RadComboBox input field. If a separator is not set, returns the text itself.
set_allowCustomTextBooleannoneAllows/Disallows the users to type text in the input area, when called with 'false' as a parameter - the input area contains only the currently selected item's text, or text obtained by all selected items' texts separated by comma or other character.
get_allowCustomTextnoneBooleanReturns true the users are allowed to type random text in the input area, false otherwise.
set_emptyMessage(string text)noneSets the EmptyMessage text of RadComboBox input field.
get_emptyMessagenonestringGets the EmptyMessage text of RadComboBox input field.
set_value(string value)noneSets the value of RadComboBox .
get_valuenonestringGets the value of RadComboBox .
showDropDownnonenoneOpens the drop-down list.
set_closeDropDownOnBlurBooleannoneIf you call the showDropDown / toggleDropDown method on a button click, you will have to use combo.set_closeDropDownOnBlur(false) right before you call the showDropDown / toggleDropDown method, otherwise the drop-down area will flicker instead of open. Then, you should use combo.set_closeDropDownOnBlur(true) in the OnClientBlur event handler. You can see a demo at: Add/Remove/Disable Items
hideDropDownnonenoneCloses the drop-down list.
toggleDropDownnonenoneToggles the drop-down list.
enablenonenoneEnables the RadComboBox. See Example 7.
disablenonenoneDisables the RadComboBox . See Example 7.
findItemByValue(string value)RadComboBoxItemReturns the first RadComboBoxItem object whose Value property equals the passed parameter.
findItemByText(string text)RadComboBoxItemReturns the first RadComboBoxItem object whose Text property equals the passed parameter.
findFirstMatchstringRadComboBoxItemReturns the first RadComboBoxItem object whose Text contains the string passed as parameter.
clearItemsnonenoneClears all items of RadComboBox .
clearSelectionnonenoneClears the selection. See Example 3.
requestItems(string text, Boolean)noneInitiates a load-on-demand callback request with the specified text, causing the ItemsRequested server event to fire or a request to be sent to a web service. The second Boolean parameter instructs the RadComboBox to append the new items ( True ) or clear items ( False ). See Example 4.
get_idnonestringGets the server-side ID of the RadComboBox instance.
get_dropDownElementnoneDOM objectGets a reference to the drop-down list.
get_inputDomElementnoneDOM objectGets a reference to the input area. See Example 5.
get_imageDomElementnoneDOM objectGets a reference to image element (drop-down toggle). See Example 6.
get_moreResultsBoxElementnoneDOM objectGets a reference to the MoreResultsBox image element.
get_moreResultsBoxMessageElementnoneDOM objectGets a reference to the MoreResultsBox Message element.
get_dropDownVisiblenoneBooleanTrue if the drop-down is opened.
set_enabledBooleannoneSets the Enabled property of the RadComboBox. To enable/disable the RadComboBox on the client-side, use the .enable() and .disable() methods of the RadComboBox client-side object. See Example 7.
get_enablednoneBooleanTrue if RadComboBox is enabled.
get_selectedItemnoneRadComboBoxItemGets the currently selected item.
get_selectedIndexnoneintegerGets the index of the currently selected item.
set_selectedIndexnoneintegerSets the selected Index of the RadComboBox. The method does not actually select an Item.
get_itemsnoneRadComboBoxItemCollectionReturns the items collection for RadComboBox .
get_enableItemCachingnonebooleanTrue if item caching is enabled (applicable in load-on-demand scenario).
set_enableItemCachingbooleannoneEnables/disables item caching (applicable in load-on-demand scenario).
attachDropDownnonenoneAttach the drop down list to the input element if it is not aligned properly, especially when a postback fires from a templated item. Use it in this scenario: Ajaxified control in ItemTemplate does a full postback.
get_visibleItemsnonearrayReturns all visible items.
setAllItemsVisibleBooleannoneSets all items visible / invisible.
get_changeTextnoneBooleanTrue if ChangeTextOnKeyBoardNavigation is true .
set_changeTextBooleannoneSets the ChangeTextOnKeyBoardNavigation property.
get_enableTextSelectionnoneBooleanTrue if EnableTextSelection is True .
set_enableTextSelectionbooleannoneSets the EnableTextSelection property.
get_markFirstMatchnoneBooleanTrue if MarkFirstMatch is true .
set_markFirstMatchBooleannoneSets the MarkFirstMatch property.
clearCachenonenoneClears the items cache if EnableItemCaching is True .
get_highlightedItemnoneRadComboBoxItemGets the currently highlighted item.

You can find a complete list of client-side methods for RadComboBox on https://docs.telerik.com/devtools/aspnet-ajax/api/client/Telerik.Web.UI.RadComboBox.

Example 1: Add a new item and persist it after a postback.

JavaScript
		
function AddNewItem() {
    var combo = $find("<%= RadComboBox1.ClientID %>");
    var comboItem = new Telerik.Web.UI.RadComboBoxItem();
    comboItem.set_text("item");
    combo.trackChanges();
    combo.get_items().add(comboItem);
    comboItem.select(); 
    combo.commitChanges();
}
	

Example 2: Set RadComboBox's text.

JavaScript
	
function SetTextOfTheComboBox() {
    var combo = $find("<%= RadComboBox1.ClientID %>"); 
    combo.set_text("CustomText");
}
	

Example 3: Clear the selection.

JavaScript
	
function ClearSelection() {
    var combo = $find("<%= RadComboBox1.ClientID %>");
    combo.clearSelection(); 
}
	

Example 4: Initiate a load-on-demand callback request with the specified text.

ASPNET
	    
<script language="javascript" type="text/javascript">
function AddItems() {
    var combo = $find("<%= RadComboBox1.ClientID %>"); 
    combo.requestItems("Item1", true);
}
</script>

<telerik:RadComboBox 
    id="RadComboBox1" 
    runat="server"
    onitemsrequested="RadComboBox1_ItemsRequested">
</telerik:RadComboBox>
<input id="Button1" type="button" value="button" onclick="AddItems()" />
	

Example 5: Set the background-color of the input area.

JavaScript
	
function ChangeInputColor() {
    var combo = $find("<%= RadComboBox1.ClientID %>");
    var inputArea = combo.get_inputDomElement();
    inputArea.style.backgroundColor = "red" 
}
	

Example 6: Set the image DOM element's src attribute.

JavaScript
	
function ChangeImageElement() {
    var combo = $find("<%= RadComboBox1.ClientID %>");
    var image = combo.get_imageDomElement();
    image.src = "MyImage.gif"; 
}
	

Example 7: Enable/disable RadComboBox on the client-side.

JavaScript
	
function ChangeEnabledState(shouldEnable) {
    var combo = $find("<%= RadComboBox1.ClientID %>");
    if (shouldEnable) {
        combo.enable();
    } else {
        combo.disable();
    }
}
	

See Also

In this article
See Also
Not finding the help you need?
Contact Support