This is a migrated thread and some comments may be shown as answers.

Display EmptyMessage if item is not in combobox

2 Answers 99 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Saqib
Top achievements
Rank 1
Saqib asked on 07 May 2009, 04:36 PM
Hi,
   I am using LoadOnDemand Combo box with AllowCustomText set to True. It's working fine.
   I have set MarkFirstMatch to True, so as soon as user starts typing the combobox will be populated with items matches the Text user has entered. But if user enters Text which doesn't bring any record that Text just stays there in combobox. What I want is when user enter text which is not in the list and change focus to some other control, I want to show the EmptyMessage.
Any suggestion or help would be appriciated.

Thanks
Saqib

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 08 May 2009, 06:55 AM
Hello Saqib,

You can try out the following code to set the EmptyMessage Text when the typed in text of the combobox does not match with the text of any comboitem:
aspx:
<telerik:RadComboBox OnClientBlur="comboBlur" EmptyMessage="-Select a value-" 
CssClass="Combo" ID="ComboCity" EnableLoadOnDemand="true"  
AllowCustomText="true" MarkFirstMatch="true" runat="server" 
DataTextField="City" DataValueField="City" DataSourceID="SqlDataSource1">             
     <CollapseAnimation Duration="200" Type="OutQuint" /> 
</telerik:RadComboBox> 

js:
function comboBlur(sender, args) 
{   
  var combotext =  sender.get_text();  
   if(sender.findItemByText(combotext)== null)   
   { 
     sender.set_text("-Select a value-"); 
   } 

Thanks
Princy.
0
Saqib
Top achievements
Rank 1
answered on 14 May 2009, 04:15 PM
It Worked
Thanks Princy
Tags
ComboBox
Asked by
Saqib
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Saqib
Top achievements
Rank 1
Share this question
or