EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: devnull on June 03, 2015, 05:02:26 AM



Title: Clear datagrid filter [Solved]
Post by: devnull on June 03, 2015, 05:02:26 AM
I have a datagrid with filter row inside a dialog box, it works great the first time it is opened, I can key text into the filter row and the record is selected and I close the dialog.

But when I re-open the dialog, I want to clear the previous text and clear the filter but I am unable to do that.

I can clear the values, but it will not redisplay all of the rows and the previous filter is still applied:
Code:
  $('#_query_').dialog({
    width: 'auto',
    height:'auto',
    closed:true,
    iconCls:'icon-filter',
    modal:true,
    onOpen: function(){
      $('input.datagrid-filter').val('');
      $('input.datagrid-filter:first').focus().trigger('change');
      $('#_query_dg').datagrid('unselectAll')
      //$('#_query_dg').datagrid('removeFilterRule');
      //$('#_query_dg').datagrid('disableFilter');
      //$('#_query_dg').datagrid('enableFilter');
      //
    }
  })

I have tried enabling & disabling the filter, triggering change, bluring and focusing the field but nothing works, the only way to get the rows to display is to hit the tab key ??


Title: Re: Clear datagrid filter
Post by: stworthy on June 03, 2015, 07:56:16 AM
To clear the filter rules, please call 'removeFilterRule' method instead.
Code:
$('#dg').datagrid('removeFilterRule', field);
$('#dg').datagrid('doFilter');


Title: Re: Clear datagrid filter
Post by: devnull on June 03, 2015, 08:08:12 AM
Thanks, that works