Back to Devexpress

ASPxClientComboBox.SetSelectedItem(item) Method

aspnet-js-aspxclientcombobox-dot-setselecteditem-x28-item-x29.md

latest1.5 KB
Original Source

ASPxClientComboBox.SetSelectedItem(item) Method

Sets the list editor’s selected item.

Declaration

ts
SetSelectedItem(
    item: ASPxClientListEditItem
): void

Parameters

NameTypeDescription
itemASPxClientListEditItem

An ASPxClientListEditItem object that specifies the item to select.

|

Remarks

Use the SetSelectedItem method on the client side to specify the selected item within the combobox editor. If a null value is passed as the parameter, no item will be selected within the editor.

The following example illustrates how to use the SetSelectedItem method.

javascript
function onLostFocus(s, e) {
    for (var i = 0; i < ComboBox.GetItemCount() ; i++) {
        var item = ComboBox.GetItem(i);
        if (item.GetColumnText('Text').toLowerCase() == s.GetText().toLowerCase()) {
            ComboBox.SetSelectedItem(item);
            break;
        }
    }
    if (ComboBox.GetValue() == null)
        ComboBox.SetText(s.GetText());
}

See Also

SetSelectedIndex(index)

GetSelectedItem

SelectedItem

SelectedIndex

ASPxClientComboBox Class

ASPxClientComboBox Members