hande89
|
|
« on: June 03, 2014, 03:27:03 AM » |
|
I got an example from here: http://www.jeasyui.com/extension/downloads/datagrid-filter.zipIf I set the list price in any row to 0, then the filters on list price column work like this: Equal works if input value is 0 Not equal works if input value is not 0 Less works if input value is >0 Greater works if input value is <0 The problem is that the row with list price 0 is always shown. Also, if I put filters Contains, Begin with and End with to Attribute column, filtering doesn't work there if any value in the column is an empty string.
|
|
« Last Edit: June 03, 2014, 06:17:24 AM by hande89 »
|
Logged
|
|
|
|
|
hande89
|
|
« Reply #2 on: June 03, 2014, 10:40:58 AM » |
|
It's fixed. Thank you!
|
|
|
Logged
|
|
|
|
hande89
|
|
« Reply #3 on: June 10, 2014, 04:47:44 AM » |
|
There's still something wrong... Filters do not work if the column's value in a row is null.
|
|
|
Logged
|
|
|
|
jarry
|
|
« Reply #4 on: June 10, 2014, 08:49:45 AM » |
|
Please download the latest 'datagrid-filter.js' file from http://www.jeasyui.com/extension/datagrid_filter.php. You may need to override the filter operators. The operator code looks like this: $.extend($.fn.datagrid.defaults.operators,{ less: { text: 'Less', isMatch: function(source, value){ return source < value; } } })
|
|
|
Logged
|
|
|
|
hande89
|
|
« Reply #5 on: June 12, 2014, 01:21:07 AM » |
|
Thanks again Working well.
|
|
|
Logged
|
|
|
|
hande89
|
|
« Reply #6 on: July 03, 2014, 04:37:35 AM » |
|
Seems that the filters are not case sensitive. But most of the time this is maybe only a matter of taste. Just to mention.
|
|
|
Logged
|
|
|
|
hande89
|
|
« Reply #7 on: August 20, 2014, 04:13:16 AM » |
|
In this example http://www.jeasyui.com/tutorial/datagrid/datagrid30_demo.htmlIf I change status values to true and false and use checkbox as the filter type: var data = [ {"productid":"FI-SW-01","productname":"Koi","unitcost":10.00,"status":true,"listprice":36.50,"attr1":"Large","itemid":"EST-1"}, {"productid":"K9-DL-01","productname":"Dalmation","unitcost":12.00,"status":true,"listprice":18.50,"attr1":"Spotted Adult Female","itemid":"EST-10"}, {"productid":"RP-SN-01","productname":"Rattlesnake","unitcost":12.00,"status":true,"listprice":38.50,"attr1":"Venomless","itemid":"EST-11"}, {"productid":"RP-SN-01","productname":"Rattlesnake","unitcost":12.00,"status":false,"listprice":26.50,"attr1":"Rattleless","itemid":"EST-12"}, {"productid":"RP-LI-02","productname":"Iguana","unitcost":12.00,"status":false,"listprice":35.50,"attr1":"Green Adult","itemid":"EST-13"}, {"productid":"FL-DSH-01","productname":"Manx","unitcost":12.00,"status":true,"listprice":158.50,"attr1":"Tailless","itemid":"EST-14"}, {"productid":"FL-DSH-01","productname":"Manx","unitcost":12.00,"status":true,"listprice":83.50,"attr1":"With tail","itemid":"EST-15"}, {"productid":"FL-DLH-02","productname":"Persian","unitcost":12.00,"status":false,"listprice":23.50,"attr1":"Adult Female","itemid":"EST-16"}, {"productid":"FL-DLH-02","productname":"Persian","unitcost":12.00,"status":true,"listprice":89.50,"attr1":"Adult Male","itemid":"EST-17"}, {"productid":"AV-CB-01","productname":"Amazon Parrot","unitcost":92.00,"status":false,"listprice":63.50,"attr1":"Adult Male","itemid":"EST-18"} ];
$(function(){ var dg = $('#dg').datagrid(); dg.datagrid('enableFilter', [{ field:'listprice', type:'numberbox', options:{precision:1}, op:['equal','notequal','less','greater'] },{ field:'unitcost', type:'numberbox', options:{precision:1}, op:['equal','notequal','less','greater'] },{ field:'status', type:'checkbox', op:['equal'] }]); }); Rows with status = false are displayed when the checkbox is checked. Otherwise, no rows are displayed when filter is enabled on that column. I get "TypeError: this.filter.resize is not a function" two times at lines 278 and 280 of datagrid-filter.js and the grid looks like in the attachment below. If I use combobox filter type, I get "too much recursion".
|
|
« Last Edit: August 20, 2014, 04:23:17 AM by hande89 »
|
Logged
|
|
|
|
hande89
|
|
« Reply #8 on: September 11, 2014, 04:46:21 AM » |
|
In this example http://www.jeasyui.com/tutorial/datagrid/datagrid30_demo.htmlIf I change status values to true and false and use checkbox as the filter type: var data = [ {"productid":"FI-SW-01","productname":"Koi","unitcost":10.00,"status":true,"listprice":36.50,"attr1":"Large","itemid":"EST-1"}, {"productid":"K9-DL-01","productname":"Dalmation","unitcost":12.00,"status":true,"listprice":18.50,"attr1":"Spotted Adult Female","itemid":"EST-10"}, {"productid":"RP-SN-01","productname":"Rattlesnake","unitcost":12.00,"status":true,"listprice":38.50,"attr1":"Venomless","itemid":"EST-11"}, {"productid":"RP-SN-01","productname":"Rattlesnake","unitcost":12.00,"status":false,"listprice":26.50,"attr1":"Rattleless","itemid":"EST-12"}, {"productid":"RP-LI-02","productname":"Iguana","unitcost":12.00,"status":false,"listprice":35.50,"attr1":"Green Adult","itemid":"EST-13"}, {"productid":"FL-DSH-01","productname":"Manx","unitcost":12.00,"status":true,"listprice":158.50,"attr1":"Tailless","itemid":"EST-14"}, {"productid":"FL-DSH-01","productname":"Manx","unitcost":12.00,"status":true,"listprice":83.50,"attr1":"With tail","itemid":"EST-15"}, {"productid":"FL-DLH-02","productname":"Persian","unitcost":12.00,"status":false,"listprice":23.50,"attr1":"Adult Female","itemid":"EST-16"}, {"productid":"FL-DLH-02","productname":"Persian","unitcost":12.00,"status":true,"listprice":89.50,"attr1":"Adult Male","itemid":"EST-17"}, {"productid":"AV-CB-01","productname":"Amazon Parrot","unitcost":92.00,"status":false,"listprice":63.50,"attr1":"Adult Male","itemid":"EST-18"} ];
$(function(){ var dg = $('#dg').datagrid(); dg.datagrid('enableFilter', [{ field:'listprice', type:'numberbox', options:{precision:1}, op:['equal','notequal','less','greater'] },{ field:'unitcost', type:'numberbox', options:{precision:1}, op:['equal','notequal','less','greater'] },{ field:'status', type:'checkbox', op:['equal'] }]); }); Rows with status = false are displayed when the checkbox is checked. Otherwise, no rows are displayed when filter is enabled on that column. I get "TypeError: this.filter.resize is not a function" two times at lines 278 and 280 of datagrid-filter.js and the grid looks like in the attachment below. If I use combobox filter type, I get "too much recursion". Seems that this is still to be fixed
|
|
|
Logged
|
|
|
|
jarry
|
|
« Reply #9 on: September 11, 2014, 08:10:14 AM » |
|
Please try to define the 'checkbox' filter before applying to the datagrid. $.extend($.fn.datagrid.defaults.filters, { checkbox:{ init: function(container, options){ var span = $('<span class="tree-checkbox tree-checkbox0" style="position:relative;top:2px"></span>').appendTo(container); span.attr('onval', options.on).attr('offval', options.off); span.bind('click',function(){ if ($(this).hasClass('tree-checkbox1')){ $(this).removeClass('tree-checkbox1').addClass('tree-checkbox0'); } else { $(this).removeClass('tree-checkbox0').addClass('tree-checkbox1'); } }); return span; }, getValue: function(target){ if ($(target).hasClass('tree-checkbox1')){ return $(target).attr('onval'); } else { return $(target).attr('offval'); } }, setValue: function(target, value){ if ($(target).attr('onval') == value){ $(target).removeClass('tree-checkbox0').addClass('tree-checkbox1'); } else { $(target).removeClass('tree-checkbox1').addClass('tree-checkbox0'); } }, resize:function(target,width){
} } })
|
|
|
Logged
|
|
|
|
hande89
|
|
« Reply #10 on: September 12, 2014, 05:20:09 AM » |
|
Your code gives "TypeError: span.attr(...) is undefined", but I got it working with this: $.extend($.fn.datagrid.defaults.filters, { checkbox:{ init: function(container, options){ var span = $('<span class="tree-checkbox tree-checkbox0" style="position:relative;top:2px" onval=1 offval=0></span>'); span.bind('click',function(){ if ($(this).hasClass('tree-checkbox1')){ $(this).removeClass('tree-checkbox1').addClass('tree-checkbox0'); } else { $(this).removeClass('tree-checkbox0').addClass('tree-checkbox1'); } }); span.appendTo(container); return span; }, getValue: function(target){ if ($(target).hasClass('tree-checkbox1')){ return $(target).attr('onval'); } else { return $(target).attr('offval'); } }, setValue: function(target, value){ if ($(target).attr('onval') == value){ $(target).removeClass('tree-checkbox0').addClass('tree-checkbox1'); } else { $(target).removeClass('tree-checkbox1').addClass('tree-checkbox0'); } }, resize:function(target,width){
} } })
|
|
|
Logged
|
|
|
|
hande89
|
|
« Reply #11 on: October 10, 2014, 01:54:59 AM » |
|
I have filters applied in datagrid and call updateRow method and then doFilter, but row is still displayed even if it does not satisfy the filter rules anymore.
|
|
|
Logged
|
|
|
|
|