EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: Berzy on July 24, 2014, 08:34:47 AM



Title: Customize datagrid filter row
Post by: Berzy on July 24, 2014, 08:34:47 AM
Another day another question... (sorry, new to this)

There is a way to add filter kind to the filter row extension?

now for dates I use:
op: ['equal', 'notequal', 'less', 'greater']

users like to add: "past 3 days", "past 3 weeks" etc etc

Thank you!


Title: Re: Customize datagrid filter row
Post by: stworthy on July 24, 2014, 03:19:39 PM
You can extend the filter operators. The 'contains' operator is defined as:
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: Customize datagrid filter row
Post by: Berzy on July 25, 2014, 03:14:16 AM
Thank you so much!


Title: Re: Customize datagrid filter row
Post by: rkpunjal on December 30, 2014, 12:17:35 PM
I have developed these for my use. Sharing it Just in case somebody needs it:

Code:
$.extend($.fn.datagrid.defaults.operators, {
    startsWith: {
        text: 'Starts With',
        isMatch: function(source, value){
            source = String(source);
            value = String(value);
            return source.toLowerCase().indexOf(value.toLowerCase()) == 0;
        }
    }
});

$.extend($.fn.datagrid.defaults.operators, {
    endsWith: {
        text: 'Ends With',
        isMatch: function(source, value){
            source = String(source);
            value = String(value);
            return source.indexOf(value, source.length - value.length) !== -1;
        }
    }
});


Title: Re: Customize datagrid filter row
Post by: rkpunjal on December 30, 2014, 12:51:29 PM
sorry "beginwith" and "endwith" are already provided ...