首页 > 代码库 > easyui filter 过滤时间段

easyui filter 过滤时间段

 1 $.extend($.fn.datagrid.defaults.filters, {
 2     dateRange: {
 3         init: function(container, options){
 4             var c = $(‘<div style="display:inline-block"><input class="d1"><input class="d2"></div>‘).appendTo(container);
 5             c.find(‘.d1,.d2‘).datebox();
 6             return c;
 7         },
 8         destroy: function(target){
 9             $(target).find(‘.d1,.d2‘).datebox(‘destroy‘);
10         },
11         getValue: function(target){
12             var d1 = $(target).find(‘.d1‘);
13             var d2 = $(target).find(‘.d2‘);
14             return d1.datebox(‘getValue‘) + ‘:‘+d2.datebox(‘getValue‘);
15         },
16         setValue: function(target, value){
17             var d1 = $(target).find(‘.d1‘);
18             var d2 = $(target).find(‘.d2‘);
19             var vv = value.split(‘:‘);
20             d1.datebox(‘setValue‘, vv[0]);
21             d2.datebox(‘setValue‘, vv[1]);
22         },
23         resize: function(target, width){
24             $(target)._outerWidth(width)._outerHeight(22);
25             $(target).find(‘.d1,.d2‘).datebox(‘resize‘, width/2);
26         }
27     }
28 });

 

1     $(‘#dg‘).datagrid().datagrid(‘enableFilter‘, [{
2         field:‘date‘,
3         type:‘dateRange‘,
4         op:[...]}]);