We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Allow Case insensitive search in AutoComplete while filtering using both text and value

Hi,

I followed the instructions here: https://ej2.syncfusion.com/javascript/documentation/auto-complete/how-to/filter/ to use autocomplete on text and value. This works great except that the search is not case-insensitive for either of the fields. For example, if I type the search as au instead of Au, it does not find anything.

I thought the predicate operator 'contains' by default was case-insensitive.

Can you please look into it?

Thanks!


4 Replies 1 reply marked as answer

UD UdhayaKumar Duraisamy Syncfusion Team October 20, 2022 11:27 AM

Hi Tera,


We are validating the requirement. We will update the further details in one business day (21st October 2022).


Regards,

Udhaya Kumar D



UD UdhayaKumar Duraisamy Syncfusion Team October 23, 2022 11:23 AM

Hi Tera,


We suggest you use the ignoreCase property for your requirement. When the ignoreCase property is set to ‘false’, consider the case-sensitive on performing the search to find suggestions.


filtering: function (e) {

    e.preventDefaultAction = true;

    var predicate = new ej.data.Predicate(

      'Name',

      'contains',

      e.text,

      (ignoreCase = true)

    );

    predicate = predicate.or('Code''contains'e.text(ignoreCase = true));

    var query = new ej.data.Query();

    query = e.text != '' ? query.where(predicate) : query;

    e.updateData(searchDataquery);

  },

 

Documentation : https://ej2.syncfusion.com/javascript/documentation/api/auto-complete/#ignorecase


Sample : https://stackblitz.com/edit/vzatmv?file=index.js


If this post is helpful, please consider Accepting it as the solution so that other members can locate it more quickly.


Regards,

Udhaya Kumar D


Marked as answer

TP Tera P Keplinger October 24, 2022 08:01 AM

Thank  you. This worked!



UD UdhayaKumar Duraisamy Syncfusion Team October 25, 2022 11:53 PM

Hi Tera,


We are glad that your requirement has been fulfilled on your end. We are always happy to assist you.


Regards,

Udhaya Kumar D


Loader.
Live Chat Icon For mobile
Up arrow icon