EasyUI Forum
May 08, 2024, 08:39:09 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: datebox filter  (Read 10166 times)
A-K
Full Member
***
Posts: 122


View Profile WWW
« on: August 03, 2014, 09:35:48 AM »

Hey,
I am using datagrid and I filter the data using filter type datebox as shown below:

Code:
$('#datagridFTA').datagrid('enableFilter', [{
field:'date',
type:'datebox',
options:{precision:1},
op:['equal','notequal','less','greater']
}]);

1) How can I make formatter and parser for the datebox in the filter so it will show the selected date like this: Day/Month/Year.
2) Also when I finally be able to make the formatter and parser for the filter, would it manage to filter my data that is already in this format (Day/Month/Year) or would I need to build a custom filter?
3) What does precision in the filter options means?


Thanks a lot! and sorry for all the questions.
Alon.
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: August 03, 2014, 05:16:26 PM »

The 'datebox' has no 'precision' property, please try the code below:
Code:
$('#datagridFTA').treegrid('enableFilter',[{
field:'begin',
type:'datebox',
options:{
formatter:function(date){
//...
},
parser:function(s){
if (!s) return new Date();
//...
}
},
op:['equal','notequal','less','dateGreater']
}]);

To compare the date value, you may need to override some operator or extend some operators and apply them to the datebox. The code below shows how to extend a new operator named 'dateGreater'.
Code:
$.extend($.fn.datagrid.defaults.operators, {
dateGreater: {
text: 'DateGreater',
isMatch: function(source, value){
var d1 = $.fn.datebox.defaults.parser(source);
var d2 = $.fn.datebox.defaults.parser(value);
return d1 > d2;
}
}
})
Logged
A-K
Full Member
***
Posts: 122


View Profile WWW
« Reply #2 on: August 04, 2014, 04:20:31 AM »

Thank you! It worked perfectly!
Logged
Opan Mustopah
Full Member
***
Posts: 164


Indonesia


View Profile Email
« Reply #3 on: October 17, 2014, 04:28:17 AM »

how to create operator for filter datebox with date range, i used this but doesn't work:
Code:
$(function(){
$.extend($.fn.datagrid.defaults.operators, {
dateCompare: {
text: 'Date Compare',
isMatch: function(source, value){
var dtr = value.split('until');
var dt1 = dtr[0].split(' ');
var dt2 = dtr[1].split(' ');

var date1 = dt1[0].split(',').toString();
var time1 = dt1[1].split(',').toString();

var date2 = dt2[0].split(',').toString();
var time2 = dt2[1].split(',').toString();

var val1  = date1.concat(' ',time1);
var val2  = date2.concat(' ',time2);

console.log(source+' '+val1+' '+val2);
return ((source >= val1) && (source <= val2));

}
}
});
});

with value ex: "2014-10-09 00:00:00 until 2014-10-17 23:59:59" and source is "2014-10-13 00:00:00"

any help appriciate, sorry for my bad english

thanks.
Logged

-- Bajak Otak --
*** Sorry for my bad english :3 ***
--JeasyUI version 1.4--
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!