cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Filter with case insensitivity

Former Member
0 Likes
9,065

Hi Experts ,

I have a search field and List in my master page . When I am searching the list Items by typing in the search field it is working only when i enter correct case . For eg : If my list item is Rizwan , In order to search I have to type Rizwan(R beign caps ) then only its working . If I type rizwan(r being small )its not working . Is there any way to remove this case sensitivity so that it should work with either case (upper and lower ) just like in Explored search functionality .

Please help with the code if possible .

Thanks

Rizwan

View Entire Topic
sebastianraemsch
Product and Topic Expert
Product and Topic Expert

Hi Rizwan,

Basically it depends on your model which you are using. As far as I know JSONModel can be filter case-insensitive but for oData it´s different. For oData it depends on the backend how filter is handled.

Please refer e.g. to this thread: https://scn.sap.com/thread/3511904

As a workaround, if backend is not changeable you may build several search strings in JavaScript to hit the 95% case (assuming sQuery is a String object):

var sQueryLower = sQuery.toLowerCase();

var sQueryUpper = sQuery.toUpperCase();

var sQueryUpLow = sQuery[0].toUpperCase() + sQuery.substr(1).toLowerCase();

aFilter.push(new Filter("ProductID", FilterOperator.Contains, sQueryLower));

aFilter.push(new Filter("ProductID", FilterOperator.Contains, sQueryUpper));

aFilter.push(new Filter("ProductID", FilterOperator.Contains, sQueryUpLow));

This is certainly not perfect but better then nothing if you can´t change the backend.


Best regards,

Sebastian