RadComboBox for ASP.NET AJAX

RadControls for ASP.NET AJAX
Note

The tlrkComboBoxes array has been removed. You should use Telerik.Web.UI.RadComboBox.ComboBoxes instead. Telerik.Web.UI.RadComboBox.ComboBoxes can be used 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:

 

Name

Parameters

Return Type

Description

trackChanges

none

none

Starts tracking changes made to RadComboBox that will be preserved over post-backs.

commitChanges

none

none

Writes the changes to RadComboBox that were made since a previous call to trackChanges, so that they are preserved over post-backs.

CopyJavaScript
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();
}

Tip

Client side changes are available on the server after postback. You can use the ClientChanges property to access them.

set_text

(string text)

none

Sets the text of the input field to the value of the specified parameter.

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

get_text

none

string

Gets the text of the input field.

get_checkedItems

none

array

Gets an array of the checked RadComboBoxItem objects.

get_lastWord

none

string

Gets the word after the last separator in the text of RadComboBox. If a separator is not set, returns the text itself.

set_emptyMessage

(string text)

none

Sets the EmptyMessage text of RadComboBox.

get_emptyMessage

none

string

Gets the EmptyMessage text of RadComboBox.

set_value

(string value)

none

Sets the value of RadComboBox.

get_value

none

string

Gets the value of RadComboBox.

showDropDown

none

none

Opens the drop-down list.

set_closeDropDownOnBlur

Boolean

none

If 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 as otherwise the drop-down area will flicker instead of open.

Then, you should use combo.set_closeDropDownOnBlur(true) in the OnClientBlur event handler. A live example can be seen at:Add/Remove/Disable Items

hideDropDown

none

none

Closes the drop-down list.

toggleDropDown

none

none

Toggles the drop-down list.

enable

none

none

Enables the RadComboBox.

disable

none

none

Disables the RadComboBox.

findItemByValue

(string value)

RadComboBoxItem

Returns the first RadComboBoxItem object whose Value property equals the passed parameter.

findItemByText

(string text)

RadComboBoxItem

Returns the first RadComboBoxItem object whose Text property equals to the passed parameter.

clearItems

none

none

Clears all items of RadComboBox.

clearSelection

none

none

Clears the selection.

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

requestItems

(string text, Boolean)

none

Initiates 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 WebService. The second bool parameter instructs the RadComboBox to append the new items (true) or clear items (false).

CopyASPX
<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()" />

get_id

none

string

Gets the server-side ID of RadComboBox instance.

get_dropDownElement

none

DOM object

Gets a reference to the drop-down list.

get_inputDomElement

none

DOM object

Gets a reference to the input area.

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

get_imageDomElement

none

DOM object

Gets a reference of the image element (drop-down toggle).

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

get_moreResultsBoxElement

none

DOM object

Gets a reference of the MoreResultsBox image element.

get_moreResultsBoxMessageElement

none

DOM object

Gets a reference of the MoreResultsBox Message element.

get_dropDownVisible

none

boolean

True if the drop-down is opened.

get_enabled

none

boolean

True if RadComboBox is enabled.

get_selectedItem

none

RadComboBoxItem

Gets the currently selected item.

get_selectedIndex

none

integer

Gets the index of the currently selected item.

get_items

none

RadComboBoxItemCollection

Returns the items collection for RadComboBox.

get_enableItemCaching

none

boolean

True if item caching is enabled (applicable in load-on-demand scenario).

set_enableItemCaching

boolean

none

Enables/disables item caching (applicable in load-on-demand scenario).

attachDropDown

none

none

Used it in this scenario: Ajaxified control in ItemTemplate does a full postback.

get_visibleItems

none

array

Returns all visible items.

setAllItemsVisible

boolean

none

Sets all items visible / invisible.

get_changeText

none

boolean

True if ChangeTextOnKeyBoardNavigation is true.

set_changeText

boolean

none

Sets the ChangeTextOnKeyBoardNavigation property.

get_enableTextSelection

none

boolean

True if EnableTextSelection is true.

set_enableTextSelection

boolean

none

Sets the EnableTextSelection property.

get_markFirstMatch

none

boolean

True if MarkFirstMatch is true.

set_markFirstMatch

boolean

none

Sets the MarkFirstMatch property.

clearCache

none

none

Clears the items cache if EnableItemCaching is True.

get_highlightedItem

none

RadComboBoxItem

Gets the currently highlighted item.

See Also