EasyUI Forum
September 14, 2025, 06:02:06 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: Datagrid Filter - default Filter selection  (Read 8402 times)
phunksta
Jr. Member
**
Posts: 54


View Profile Email
« on: January 22, 2015, 04:40:13 AM »

Hi, I would like to know if this is possible, and maybe how to go about it?

I am using Datagrid Filter Row extension. My users want the Menu for each filter e.g. 'equal','beginwith' etc.
They would also like the 'filterDelay' style filtering where anything entered in the filter input can start filtering.

I can see that by using 'text' type with 'op' unspecified and 'filterDelay' set, that the defaultFilterOperator is applied automatically.

Is it possible to doFilter if, say the user enters into the box and then presses a certain key?
If no filter type is set I'd like to apply defaultFilterOperator, or if they previously chose another option then to stick with that and go ahead to 'doFilter'?

I have managed to get an individual filter input to do this by changing its options, but I can't work out how to apply this to all of my filters whenever they are built. Sad

Any help gladly received!
Logged
phunksta
Jr. Member
**
Posts: 54


View Profile Email
« Reply #1 on: February 23, 2015, 03:04:10 AM »

It didn't seem that anyone could help me with this unfortunately.
I was able to achieve it though, but not with an override or extend, I had to insert code into the source file which was less-than-elegant, but hey, sometimes the user just gotta get what the user wants!

So, at line 649 in datagrid-filter.js, I added the following:

Code:
//mod - set default filter on return keypress
$(input[0]).keypress(function (e) {
if (e.keyCode == 13) {
var input = $(e.target);
var field = input.attr('name');
var rule = $(target).datagrid('getFilterRule', field);
var value = input.val();
if (value != '') {
if ((rule && rule.value != value) || !rule) {
var setop = opts.defaultFilterOperator;
if (rule)
    setop = rule.op;
$(target)[name]('addFilterRule', {
    field: field,
    op: setop,
    value: value
});
$(target)[name]('doFilter');
}
} else {
if (rule) {
$(target)[name]('removeFilterRule', field);
$(target)[name]('doFilter');
}
}
    }
});
//end mod
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!