jQuery EasyUI Extension - DataGrid Row Filter
Usage
Include 'datagrid-filter.js' File
<script type="text/javascript" src="datagrid-filter.js"></script>
Enable Filter
var dg = $('#dg');
dg.datagrid(); // create datagrid
dg.datagrid('enableFilter'); // enable filter
Properties
This property extends from datagrid, and the following properties are added to datagrid.
Name | Type | Description | Default Value |
---|---|---|---|
filterMenuIconCls | string | The icon class for the filter menu item (indicating the item to use). | icon-ok |
filterBtnIconCls | string | The icon class for the filter button. | icon-filter |
filterBtnPosition | string | The position of the filter button. Possible values are 'left' and 'right'. | right |
filterPosition | string | The position of the filter bar relative to the column. Possible values are 'top' and 'bottom'. | bottom |
remoteFilter | boolean | Set to true to perform remote filtering. <br>When enabled, the 'filterRules' parameter will be sent to the remote server. <br>The value of the 'filterRules' parameter is obtained from the 'filterStringify' function. | false |
filterDelay | number | The delay time to perform filtering from the last key input event in the 'text' filter component. | 400 |
filterRules | array | The definition of filter rules. Each rule contains 'field', 'op', and 'value' properties. | [] |
filterStringify | function | The function to stringify the filter rules. | function(data){<br> return JSON.stringify(data);<br>} |
Methods
The following methods extend from datagrid.
Name | Parameters | Description |
---|---|---|
enableFilter | filters | Create and enable the filter function. <br>'filters' parameter is an array of filter configurations. <br>Each item contains the following properties: <br>1) field: The field to define the rule. <br>2) type: The filter type, possible values: label, text, textarea, checkbox, numberbox, validatebox, datebox, combobox, combotree. <br>3) options: The options for the filter type. <br>4) op: The filter operation, possible values: contains, equal, notequal, beginwith, endwith, less, lessorequal, greater, greaterorequal. Example code: $('#dg').datagrid('enableFilter');<br>$('#dg').datagrid('enableFilter', [{<br> field:'listprice',<br> type:'numberbox',<br> options:{precision:1},<br> op:['equal','notequal','less','greater']<br>}]); |
addFilterRule | param | Add a filter rule. Example: $('#dg').datagrid('addFilterRule', {<br> field: 'desp',<br> op: 'contains',<br> value: 'easyui'<br>}); |
removeFilterRule | field | Remove a filter rule. <br>If the 'field' parameter is not specified, remove all filter rules. |
doFilter | none | Perform filtering based on filter rules. |
getFilterComponent | field | Get the filter component on the specified field. |
Download jQuery EasyUI Example
jquery-easyui-datagrid-filter.zip