/** * yvan.yvgrid.filter.js * @author luoyifan * 2019-07-16 20:09:00 */ 'use strict'; (function ($) { $.extend($.fn.yvgrid.methods, { clearfilters: function ($dom) { return $dom.jqxGrid('clearfilters'); } }); $.fn.yvgrid.filter = { sourceFilterOption: function ($dom, easyuiOpt, source, jqxOption) { if (source.datatype === 'array') { //本地过滤 $.extend(jqxOption, { virtualmode: false, rendergridrows: null, }); } else { //服务器过滤 $.extend(source, { filter: function () { $dom.jqxGrid('updatebounddata', 'filter'); }, }); } }, columnFilterOption: function ($dom, easyuiOpt, easyuiColumnOpt, jqxColumnOpt) { if (!easyuiOpt.filter) { return; } if (easyuiColumnOpt.filter === false) { $.extend(jqxColumnOpt, { filterable: false }); return; } switch (easyuiColumnOpt.type) { case 'number': $.extend(jqxColumnOpt, { filtertype: 'textbox', createfilterwidget: function (column, columnElement, widget) { //这里要修改 jqxgrid.filter.js 源码 1861 / 1867 / 2156 //搜索 if(K.keyCode=="13"){I._applyfilterfromfilterrow()}if(f[0]._writeTimer){clearTimeout(f[0]._writeTimer)}f[0]._writeTimer=setTimeout //替换 if(K.keyCode=="13"){I._applyfilterfromfilterrow()}if(f[0]._writeTimer){clearTimeout(f[0]._writeTimer)}if(K.keyCode == "13"){/*luoyifan*/ return;}f[0]._writeTimer=setTimeout //搜索 if(L!=0){H=H.substring(L);if(H.length<1){return false}}}if(j.filtercondition!=undefined){K=j.filtercondition}if(M=="datefilter") //替换 /*luoyifan*if(L!=0){H=H.substring(L);if(H.length<1){return false}}*/}/*if(j.filtercondition!=undefined){K=j.filtercondition}*/if(M=="datefilter") widget.on('input propertychange', function (event) { this.value = this.value.replace(/[^\d\\><=.]/g,""); }); } }); break; case 'date': $.extend(jqxColumnOpt, { filtertype: 'range' }); break; case 'bool': $.extend(jqxColumnOpt, { filtertype: 'bool', createfilterwidget: function (column, columnElement, widget) { widget.jqxCheckBox({}); } }); break; default: //判断 formatter 是不是字典 if ($.type(easyuiColumnOpt.formatter) === 'array') { $.extend(jqxColumnOpt, { filtertype: 'checkedlist', createfilterwidget: function (column, columnElement, widget) { widget.jqxDropDownList({ displayMember: 'text', valueMember: 'id', source: easyuiColumnOpt.formatter }); } }); } else { //字符串 $.extend(jqxColumnOpt, { filtertype: 'textbox', //createfilterwidget: function (column, columnElement, $dom) { // //debugger // //var $dom = $('').appendTo(columnElement); // //var me = this; // $dom.jqxInput({ // width: '100%' // }).css({ // margin: "4px 4px" // }); //}, //createfilterwidget: function (column, columnElement, widget) { // debugger // widget.jqxInput({ // width: '100%' // }); //} }); } } }, /** * 表格设置 */ gridOption: function ($dom, easyuiOpt, jqxOpt) { if (easyuiOpt.filter) { //需要修改 jqxGrid.filter.js 1989/2001行 $.extend(jqxOpt, { showfilterrow: true, filterable: true, autoshowfiltericon: true, updatefilterconditions: function (type, defaultconditions) { switch (type) { case 'stringfilter': return ['CONTAINS']; case 'numericfilter': return ['GREATER_THAN', 'LESS_THAN']; case 'datefilter': return ['EQUAL']; case 'booleanfilter': return ['EQUAL']; } } }); } else { $.extend(jqxOpt, { filterable: false, }); } delete jqxOpt.filter; } }; })(jQuery);