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

AutoComplete filtering event fired with empty value

3 Answers 1221 Views
AutoComplete
This is a migrated thread and some comments may be shown as answers.
Gonzalo
Top achievements
Rank 1
Gonzalo asked on 12 Jan 2015, 12:47 AM
Hello,
I've got an autocomplete widget bound to a remote datasource, and with data-min-length set to 5.
All is working quite fine, but if the widget content is deleted (using delete or backspace keys), the filtering event is fired with an empty value, ignoring the data-min-length. Is this the expected behavior?
Thanks in advance,

3 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 13 Jan 2015, 04:03 PM
Hello Gonzalo,

The described behavior is expected. We received a feedback about previous behavior (when the widget did not perform request on empty input) with the argument that it is not expected by the end users to do nothing when input value is cleared.
If you want to change the default behavior, you can wire the filtering event and prevent the request if the filter value is empty string.

Regards,
Georgi Krustev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Gonzalo
Top achievements
Rank 1
answered on 13 Jan 2015, 05:21 PM
Hello Georgi, and thanks for your answer.
As you suggested, I wired the filtering event, and prevented the default behavior, so now the request isn't fired when the value is an empty string. However, the component continues showing the last result set, and in my opinion it isn't the expected behavior from the user point of view. I have more than 6000 rows in the backend data set, so showing the entire data set in the autocomplete isn't an option.
I would like to prevent the request and clean the previous result on empty string, or even when the filter length is under the data-min-length. I think I can do it server side, returning an empty result, but doing unneeded request to the server isn't very efficient.
It can be done client side?
Regards,
0
Georgi Krustev
Telerik team
answered on 14 Jan 2015, 11:26 PM
Hello Gonzalo,

You can get the widget's data source and clear the shown data using its data method:
filtering: function(e) {
   if ([condition]) {
     e.preventDefault();
     e.sender.dataSource.data([]);
   }
}

Let me know if I can be of a further assistance.

Regards,
Georgi Krustev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
AutoComplete
Asked by
Gonzalo
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Gonzalo
Top achievements
Rank 1
Share this question
or