AutoComplete filtering event fired with empty value

4 posts, 0 answers
  1. Gonzalo
    Gonzalo avatar
    2 posts
    Member since:
    Dec 2012

    Posted 11 Jan 2015 Link to this post

    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,
  2. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3706 posts

    Posted 13 Jan 2015 Link to this post

    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!
     
  3. Kendo UI is VS 2017 Ready
  4. Gonzalo
    Gonzalo avatar
    2 posts
    Member since:
    Dec 2012

    Posted 13 Jan 2015 in reply to Georgi Krustev Link to this post

    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,
  5. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3706 posts

    Posted 14 Jan 2015 Link to this post

    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!
     
Back to Top
Kendo UI is VS 2017 Ready