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

Setting a filter doesn't return the existing filter?

1 Answer 122 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Troy
Top achievements
Rank 1
Troy asked on 01 Feb 2017, 10:20 PM

The docs for DataSource.filter() indicate that it returns "the current filter configuration. Returns null if no filter criteria are currently applied. Returns undefined if the DataSource instance has not performed filtering so far."  I took this to mean if I set a filter via oldFilter = ds.filter(myFilter), I would get the existing filter config back as "oldFilter", just as if I had called oldFilter = ds.filter() without setting one - its a common pattern for setters.  However, the method seems to always return "undefined" in all cases when you set a filter.  I've created a dojo example.

Am I misreading the intent, and setting a filter wasn't supposed to return the current filter?  If so, the "RETURNS"  phrasing in the docs really should be clarified. But in that case this might be a worthwhile feature request, since writing "oldFilter = ds.filter(myFilter)" can be more convenient than doing it in two lines "oldFilter = ds.filter(); ds.filter(myFilter)".  It looks like the group() method and perhaps others have the same ambiguity.

1 Answer, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 03 Feb 2017, 02:23 PM
Hello Troy,

This behaviour is by design.

Getting the current filter first and then setting the new one is the designed approach in this scenario.

After consulting with the developers' team, for now, we do not plan to change this based on the current implementation of the filter.

Regards,
Stefan
Telerik by Progress
Try our brand new, jQuery-free Angular 2 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
Troy
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Share this question
or