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

Determining what filters are set

1 Answer 109 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Andrew
Top achievements
Rank 1
Andrew asked on 30 Dec 2011, 02:17 AM
Can you give a code example of how to determine what filters are currently set?   I get that dataSource.filter() will give me back the objects, but how to I decode it?

For example, if I set a filter on a field "product" as "eq" to value "Milk", then later want to get the value of "Milk" back, how would I do so?

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 30 Dec 2011, 02:22 PM
Hello Andrew,

The filter object has three fields from which you could get information about it - field, operator and value.
So to get the values used to filter the "product" field you can use something similar to the snippet below:
$(dataSource.filter().filters).each(function(){
    if(this.field == "product"){
        alert(this.value);
    }
});


Regards,
Daniel
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Data Source
Asked by
Andrew
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or