EasyUI Forum
May 16, 2024, 09:33:51 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: How to arrange datagrid filtering for different locales?  (Read 991 times)
aerdem
Newbie
*
Posts: 5


View Profile Email
« on: October 26, 2022, 10:43:39 AM »

We are using easyui for jquery in our application.

In one of the pages I have a datagrid and this datagrid uses clientpaging.
Code:
                  $('#dgTable').datagrid({
                        url:null,
                        autoLoad: true,
                        pageList: [10, 20, 50, 100],
                        clientPaging: true,
                        rownumbers: true,
                        filterMatchingType:'all'
                    });

In this datagrid I added a filter.

Code:
 $('#dgTable').datagrid('enableFilter', [
                         {
        field: 'fieldName',
        type: 'textbox',
        op: ['contains','equal','notequal'],
        options: {
            onChange: function (value) {
                if (value == '') {
                    $('#dgTable').datagrid('removeFilterRule', 'criteriaField');
                } else {
                    $('#dgTable').datagrid('addFilterRule', {
                        field: 'criteriaField',
                        op:  'contains',
                        value: value
                    });
                }
                $('#dgTable').datagrid('doFilter');
            }
        }
    }
                    ]);
It is working for ascii characters but for Turkish specific characters such as ı,İ,Ö,ö,Ü,ü,Ç,ç,Ş,ş,Ğ,ğ it does not work.

Is there any way of using Turkish specific characters for filtering data in datagrid.

Best regards


« Last Edit: October 26, 2022, 10:35:09 PM by aerdem » Logged
jarry
Administrator
Hero Member
*****
Posts: 2264


View Profile Email
« Reply #1 on: October 26, 2022, 07:33:19 PM »

The filter operators can be overridden to meet your needs.
Code:
$.extend($.fn.datagrid.defaults.operators, {
    contains: {
        text: 'Contains',
        isMatch: function (source, value) {
            source = String(source);
            value = String(value);
            return source.toLowerCase().indexOf(value.toLowerCase()) >= 0;
        }
    }
})
Logged
aerdem
Newbie
*
Posts: 5


View Profile Email
« Reply #2 on: October 26, 2022, 10:32:55 PM »

It is working.

I replaced
Code:
toLowerCase()
with
Code:
toLocaleLowerCase('tr-TR') 
for Turkish specific characters.

@jarry Thanks a lot for your help.
« Last Edit: October 26, 2022, 10:35:47 PM by aerdem » Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!