EasyUI Forum
October 30, 2020, 06:30:56 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: Datebox filter range  (Read 9395 times)
A-K
Full Member
***
Posts: 122


View Profile WWW
« on: August 05, 2014, 09:05:58 AM »

Hey, in a previous thread I got an answer about how to create formatter and parser for datebox filter
and how to create custom filters for date.
but now I need to make a filter with date range like "show all dates that are between: 01/08/2014 - 05/08/2014"
and I didnt know how to make the datebox show range selection.

Please is there a way to make the datebox in the datagrid filter to show range selection? I will then create the custom filter.

Thanks, Alon.
« Last Edit: August 05, 2014, 09:07:51 AM by AlonKatz » Logged
stworthy
Administrator
Hero Member
*****
Posts: 3576


View Profile Email
« Reply #1 on: August 06, 2014, 07:54:20 AM »

Please use the latest 'datagrid-filter.js' file, it can be downloaded from http://www.jeasyui.com/extension/datagrid_filter.php. And then extend a new filter to allow the user to select a date range.
Code:
$.extend($.fn.datagrid.defaults.filters, {
dateRange: {
init: function(container, options){
var c = $('<div style="display:inline-block"><input class="d1"><input class="d2"></div>').appendTo(container);
c.find('.d1,.d2').datebox();
return c;
},
destroy: function(target){
$(target).find('.d1,.d2').datebox('destroy');
},
getValue: function(target){
var d1 = $(target).find('.d1');
var d2 = $(target).find('.d2');
return d1.datebox('getValue') + ':'+d2.datebox('getValue');
},
setValue: function(target, value){
var d1 = $(target).find('.d1');
var d2 = $(target).find('.d2');
var vv = value.split(':');
d1.datebox('setValue', vv[0]);
d2.datebox('setValue', vv[1]);
},
resize: function(target, width){
$(target)._outerWidth(width)._outerHeight(22);
$(target).find('.d1,.d2').datebox('resize', width/2);
}
}
});

Apply this filter to a date field.
Code:
$('#dg').datagrid().datagrid('enableFilter', [{
field:'date',
type:'dateRange',
op:[...]
}]);
« Last Edit: August 06, 2014, 07:59:04 AM by stworthy » Logged
A-K
Full Member
***
Posts: 122


View Profile WWW
« Reply #2 on: August 08, 2014, 03:14:13 AM »

Thank you!
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!