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

Removing all the items on itemsrequest event in javasript

2 Answers 66 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Sampada
Top achievements
Rank 1
Sampada asked on 18 Feb 2012, 11:04 AM

Team

 

I am using rad combobox in my application for searching.

Whenever user type something in combobox it shows me related data.

I have used OnItemsRequested event for this.

I am having requirement that result drop down won’t show up until I type 3 charactors in combobox

I am using OnClientItemsRequesting event as follow to suppressed OnItemsRequested event.

 

  function onItemsRequesting(sender, eventArgs) {

            if (eventArgs.get_text().length < 3) {

                sender.hideDropDown();

                eventArgs.set_cancel(true);

            }

            else {

                sender._loadingMessage = "Searching for " + eventArgs.get_text() + "...";

            }

         }

I am using telerik V2011.3.1115.40

Initially combo doesn’t contain any items. It is working fine first time but whenever I remove the characters & number of characters  become to 2 & press another letter even then it shows me previous result for few seconds & then shows proper result. Is there any reason for this?

Can you please let me know how to remove all the items of the radcombobox in OnClientItemsRequesting event?

It might resolve the problem.

If you have any other resolution for this please let me know.

2 Answers, 1 is accepted

Sort by
0
Accepted
Veselin Vasilev
Telerik team
answered on 20 Feb 2012, 12:12 AM
Hello Sampada,

You can try the following:

function onItemsRequesting(sender, eventArgs) {
  
            if (eventArgs.get_text().length < 3) {
                sender.get_items().clear();
                eventArgs.set_cancel(true);
                sender.hideDropDown();
            }
  
            else {
  
                sender._loadingMessage = "Searching for " + eventArgs.get_text() + "...";
  
            }
 }


Please check the online help for the full list of RadCombobox's client-side methods


Kind regards,
Veselin Vasilev
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Sampada
Top achievements
Rank 1
answered on 20 Feb 2012, 10:26 AM
Thanks 
It is working as expected.
Tags
ComboBox
Asked by
Sampada
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
Sampada
Top achievements
Rank 1
Share this question
or