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

What to do when "Load on demand" returns nothing

1 Answer 65 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Thierry Baertschiger
Top achievements
Rank 1
Thierry Baertschiger asked on 30 Nov 2010, 10:14 AM
Hello. 

I need some suggestions/ideas...

I use a RadComboBox with "EnableLoadOnDemand=true" and a web service. With these settings I cannot change the value of the property "AllowCustomText": it cannot be different from true as explained here:  http://www.telerik.com/help/aspnet-ajax/cannot-disable-allowcustomtext-load-on-demand.html.

The problem that I have is that the combo box displays a closed list, which means that it should not allow the user to select a value which is not in that list. But with the "AllowCustomText = true", nothing prevents the user from doing this. 

What can I do to tell the user that he/she has entered something not allowed ? Has anybody some ideas to do something nice in that case ?

I like what is done here http://demos.telerik.com/aspnet-ajax/combobox/examples/functionality/autocompleteclientside/defaultcs.aspx when "AllowCustomText = false" : the user cannot enter letters when there is no match in the combo box. 

Note that I have tried what is proposed in the above link but this is not OK since there is no call to the web server when the user enter some text in the combo box. 

Thierry

1 Answer, 1 is accepted

Sort by
0
Cori
Top achievements
Rank 2
answered on 01 Dec 2010, 07:09 PM
Hello Thierry,

My suggestion would be handle the OnClientKeyPressing event and in there check if what they typed exists in the results returned from the LoadOnDemand request. If no results were returned, you can cancel the key press and then display an alert telling them no items exist or something like that. Like so:

function OnClientKeyPressing(sender, args){
     var textTyped = sender.get_text();
     if(sender.get_items().length == 0){         
         alert("No Items Exist!");
         args.set_cancel(true);
     }
}

I hope that helps. 
Tags
ComboBox
Asked by
Thierry Baertschiger
Top achievements
Rank 1
Answers by
Cori
Top achievements
Rank 2
Share this question
or