This is a migrated thread and some comments may be shown as answers.

dataSource.filter running twice

1 Answer 128 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Bridge24
Top achievements
Rank 1
Iron
Bridge24 asked on 15 Jun 2018, 05:16 PM

In our app, we are using "custom filtering", as we set our own function in the "operator" property of the filter.

I found, that, every operator is called twice.  If I have 10 rows to filter, and 1 operator set for 1 specific filter, it runs 20 times, from 1 to 10, and again from 1 to 10.

Steps to reproduce: 

http://dojo.telerik.com/@foxontherock/EfOyiwIS

After some investigation, I found this:

In your "query" function, you run this: 

(copied from the minified version + chrome prettyPrint in F12)
result = this._queryProcess(this._data, this._mergeState(options)); 

The filter is applied.

Then, a few lines later, that:

this._aggregateResult = this._calculateAggregates(this._data, options);

And, from that line, the whole filtering is applied again.

When we have only a few lines to filter, it's quick. 

But with 5000 rows of 10 filters per row, running it twice is a good difference in cpu, memory and time!

You can look at my dojo sample, it's easy to reproduce.

 

1 Answer, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 18 Jun 2018, 07:47 AM
Hello, Daniel,

Thank you for the example and all of the details.

This occurs because the filter is called again when the aggregates are calculated.

1) https://github.com/telerik/kendo-ui-core/blob/master/src/kendo.data.js#L1726
2) https://github.com/telerik/kendo-ui-core/blob/master/src/kendo.data.js#L3628

I will forward this to the developers' team to check if we can only execute the second filter if there are aggregates or grouping.

Regards,
Stefan
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Data Source
Asked by
Bridge24
Top achievements
Rank 1
Iron
Answers by
Stefan
Telerik team
Share this question
or