Edit this page

AllowCustomText Cannot Be Disabled When Loading Items on Demand

When you load the combobox items on demand (in the ItemsRequested event) the AllowCustomText property is enabled by default. You cannot disable it as this would break the load-on-demand mechanism.

The ItemsRequested event is fired when the user types in the Telerik RadComboBox input field or clicks the drop-arrow image. Disabling the AllowCustomText property would prevent the user from typing in the input field and this would break the load-on-demand mechanism. Therefore we decided that the best approach is to hard-code the value of the AllowCustomText property and set it to true when the combobox is in a callback mode.

WORKAROUND

To work around the problem you could use the following approach:

  • Do not enable the load on demand mechanism

  • Subscribe to the OnClientDropDownOpening event and call the requestItems() method of the combobox to load the items from the ItemsRequested server-side event

<telerik:RadComboBox RenderMode="Lightweight" 
    id="RadComboBox1" 
    AllowCustomText="false" 
    OnClientDropDownOpening="OnClientDropDownOpeningHandler"
    OnItemsRequested="RadComboBox1_ItemsRequested" 
    runat="server">
</telerik:RadComboBox>

function OnClientDropDownOpeningHandler(sender, eventArgs) {
    sender.requestItems("", false);
}


protected void RadComboBox1_ItemsRequested(object o, Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs e)
{
    RadComboBox1.Items.Add(new RadComboBoxItem("item 1", "1"));
    RadComboBox1.Items.Add(new RadComboBoxItem("item 2", "2"));
}