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
$("#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