EasyUI Forum
April 28, 2024, 08:14:00 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Customize datagrid filter row  (Read 8200 times)
Berzy
Newbie
*
Posts: 7


View Profile Email
« 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!
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 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;
}
}
});
Logged
Berzy
Newbie
*
Posts: 7


View Profile Email
« Reply #2 on: July 25, 2014, 03:14:16 AM »

Thank you so much!
Logged
rkpunjal
Newbie
*
Posts: 15


View Profile
« Reply #3 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;
        }
    }
});
Logged
rkpunjal
Newbie
*
Posts: 15


View Profile
« Reply #4 on: December 30, 2014, 12:51:29 PM »

sorry "beginwith" and "endwith" are already provided ...
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!