EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: A-K on August 19, 2014, 08:35:07 AM



Title: onLoadSuccess is called twice with filter extension
Post by: A-K on August 19, 2014, 08:35:07 AM
Hey, Is there a reason that when using the filter extension the 'onLoadSuccess' will be called twice,
once when the real data is loaded and once when the enable filter code runs (
Code:
$('#dg').datagrid('enableFilter');
)

Its making my code not efficient because I have some serious code in the 'onLoadSuccess' and because
of this I need to check if its called once or twice which makes the code look really bad...

Thanks, Alon.


Title: Re: onLoadSuccess is called twice with filter extension
Post by: stworthy on August 19, 2014, 07:28:43 PM
The 'datagrid-filter.js' has been improved, please download it from http://www.jeasyui.com/extension/datagrid_filter.php


Title: Re: onLoadSuccess is called twice with filter extension
Post by: A-K on August 19, 2014, 10:13:48 PM
Thanks, the problem is fixed.


Title: Re: onLoadSuccess is called twice with filter extension
Post by: Stefan B. on September 01, 2014, 06:35:18 AM
I have the same problem! *And it is NOT fixed with the extension file from today.*
I'am using remote filter and the remote data is loaded twice! And the the onLoadSuccess is called also twice.

It is only a problem if I enable the filter!


Title: Re: onLoadSuccess is called twice with filter extension
Post by: stworthy on September 01, 2014, 07:21:22 AM
If you have the 'filterRules' property initialized, the data will be loaded again when calling 'enableFilter' method.


Title: Re: onLoadSuccess is called twice with filter extension
Post by: Stefan B. on September 01, 2014, 11:19:45 PM
OK. But this is what we should done. Jerry wrote this on the bug report http://www.jeasyui.com/forum/index.php?topic=3698.0
So, every time we enable the filte we do something like this
Code:
$('#dg1').datagrid({filterRules:[]}).datagrid('enableFilter');
$('#dg2').datagrid({filterRules:[]}).datagrid('enableFilter');

I try to remove the code datagrid({filterRules:[]}) , and then it fixed!

But what should we do with the bug on http://www.jeasyui.com/forum/index.php?topic=3698.0 ???

Update: In the datagrid-filter.js the was the line 477 commented out. Is that the correct code to init the filter and fix the other bug?


Title: Re: onLoadSuccess is called twice with filter extension
Post by: stworthy on September 02, 2014, 12:40:18 AM
The 'datagrid-filter.js' has been updated, please try to download it from http://www.jeasyui.com/extension/datagrid_filter.php.


Title: Re: onLoadSuccess is called twice with filter extension
Post by: Stefan B. on September 02, 2014, 01:08:05 AM
THX - That works.