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

Datasource filter multiple

1 Answer 119 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Serdar Kilic
Top achievements
Rank 1
Serdar Kilic asked on 13 Feb 2017, 04:35 AM

I'm using the Datasource object to retrieve data from a remote (JSON) datasource which I would then like to filter client-side without doing any round-trips back to the server. I get the results fine but I'm unable to clear and reapply filters, my code is:

dsReport.fetch().then(function(){

    
    var view = dsReport.view();
    
    dsReport.filter({field:"Occupation", operator: "equals", value:"DEVELOPER"})
    
    console.log(view[0].NumberOfStaff); //Outputs 13 which is correct
       
    dsReport.filter({}); //Remove the previous filter??
    
    dsReport.filter({field:"Occupation", operator: "equals", value:"MANAGER"})
    
    console.log(view[0].NumberOfStaff); //Outputs 13, should be 22, assuming new filter isn't being considered
    
})

1 Answer, 1 is accepted

Sort by
0
Alex Hajigeorgieva
Telerik team
answered on 13 Feb 2017, 11:29 AM
Hi Serdar,

The reason for this behaviour is because the view variable is holding a reference to the Kendo UI DataSource view at an earlier stage. To get the updated view, another call to the data source view() method should be made after the filter is applied or removed. 

For your convenience, a simple demo is available at:

http://dojo.telerik.com/EgEyu

Should you need further help, please feel free to ask.

Kind Regards,
Alex Hajigeorgieva
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 (charts) and form elements.
Tags
Data Source
Asked by
Serdar Kilic
Top achievements
Rank 1
Answers by
Alex Hajigeorgieva
Telerik team
Share this question
or