EasyUI Forum
April 25, 2024, 11:27:08 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: Datagrid Row Filter does-not work well with columns having formatter  (Read 13043 times)
rkpunjal
Newbie
*
Posts: 15


View Profile
« on: January 03, 2015, 09:44:55 AM »

if you enabled filter on a datagrid using  $("#my-dg").datagrid('enableFilter');   and if your datagrid has a column with a formatter eg:
<th field="state" width="100px" sortable="true" formatter="cityMaster.showStateInGrid" ></th>
Then filtering won't work on that column.
Meaning typing into the filter-box will fail and blank-out the grid.

But I managed to fix this.
Attached is the filter plugin with the fix. I took the latest-code and applied my fix on this.
Features:
  • Automatically uses the formatter specified in the datagrid for that column and no need to write any extra code. Compares value with the formatted data.

    Works well with a combo-box setup in your filter. eg: as below

Code:
    $("#city-dg").datagrid('enableFilter', [
        {
            field:'state',
            type:'combobox',
            options:{
                panelHeight:'auto',
                data: filterStateComboboxData,  // my data for the combo-filter
                onChange:function(value){
                    if (value == null || value == ''){
                        $("#city-dg").datagrid('removeFilterRule', 'state');
                    } else {
                            $("#city-dg").datagrid('addFilterRule', {
                            field: 'state',
                            formatter: showStateInGrid,             // point to the formatter
                            op: 'equal',
                            value: value
                        });
                    }
                    $("#city-dg").datagrid('doFilter');
                }
            }
        }
    ]);


This works well !!

But I feel that the JEasy-UI developers should take a look at it and 'optimize' the code as per their coding standards.
Incase you choose to apply this as a patch, please let me know, so that I can download the latest filter-plugin then.

cheers,
Ram
« Last Edit: January 03, 2015, 09:46:41 AM by rkpunjal » Logged
fguibert
Newbie
*
Posts: 23


View Profile
« Reply #1 on: February 12, 2019, 03:13:39 AM »

+1 I had the same problem, filters behavior should be natively the same as sorters : using the column's real value instead of the formatted value.
thanks for the patch
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!