EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: aerdem on October 26, 2022, 10:43:39 AM



Title: How to arrange datagrid filtering for different locales?
Post by: aerdem 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




Title: Re: How to arrange datagrid filtering for different locales?
Post by: jarry 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;
        }
    }
})


Title: Re: How to arrange datagrid filtering for different locales?
Post by: aerdem 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.