EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: A-K on February 02, 2015, 08:00:36 AM



Title: Filter event
Post by: A-K on February 02, 2015, 08:00:36 AM
Hey,

I didnt find a way to know when a user has filtered the datagrid, is there an event that I missed?
I only saw the onClickMenu in the extension.

Thanks.


Title: Re: Filter event
Post by: jarry on February 02, 2015, 05:02:19 PM
After calling the 'doFilter' method, the filtered data will be loaded. When this happens, the 'onLoadSuccess' event fires.


Title: Re: Filter event
Post by: A-K on February 02, 2015, 10:55:24 PM
But I am not calling doFilter.  I just enabled filters on the
datagrid and I need to know when the user has filtered
the datagrid,  like for example when he typed something
in any column.


Title: Re: Filter event
Post by: jarry on February 02, 2015, 11:52:00 PM
The 'doFilter' method is called internally. Once the filtering action is finished, the 'onLoadSuccess' event fires.


Title: Re: Filter event
Post by: A-K on February 03, 2015, 03:36:37 AM
Oh but there is a small problem with this situation, I have a lot of code in the onLoadSuccess which I am using
when the datagrid is loaded but I do not want to use it when the user has filterd the datagrid.

Could you create an event for the filter so I could at least use a bool to know when its from the filter...

Thanks.


Title: Re: Filter event
Post by: jarry on February 03, 2015, 09:06:48 AM
Please try to detect the 'filterRules' property value in the 'onLoadSuccess' event. If the 'filterRules' is not empty, the data should be loaded from the filters.
Code:
$('#dg').datagrid({
onLoadSuccess:function(data){
var opts = $(this).datagrid('options');
console.log(opts.filterRules)
}
});