EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: devnull on May 15, 2015, 05:42:13 PM



Title: Datagrid Filter without Filter bar
Post by: devnull on May 15, 2015, 05:42:13 PM
I would like to set filters on the datagrid using external elements and not the Filter Bar, how can I do this  as this does not appear to work:

Code:
    var dg = $('#xxx');
    dg.datagrid('removeFilterRule','XX_X');
    dg.datagrid('addFilterRule', {
      field: 'XX_X',
      op: 'equal',
      value: 'myValue'
    });
   
    dg.datagrid('doFilter');



Title: Re: Datagrid Filter without Filter bar
Post by: stworthy on May 16, 2015, 01:53:29 AM
You must call 'enableFilter' method to enable the filter functionality before calling 'doFilter' method.
Code:
var dg = $('#xxx');
dg.datagrid('enableFilter');
dg.datagrid('removeFilterRule','XX_X');
dg.datagrid('addFilterRule', {
  field: 'XX_X',
  op: 'equal',
  value: 'myValue'
});

dg.datagrid('doFilter');

If you want to hide the filter bar, please add the code below to the page.
Code:
<style>
.datagrid-filter-row{
display: none;
}
</style>