Monday, May 8, 2017

Getting all filters in kendo angular grid



How would I get a list of all the filters being used in a kendo angular grid?
https://www.telerik.com/kendo-angular-ui/components/grid/api/GridComponent/



I have access to the grid in my angular component like so



@ViewChild(GridComponent) private grid;



I set the remote data



this.dataService.getItems().subscribe(
data => {
this.grid.data = data;
}
)


I have to call an API similar to this. I tried using the filterChange event - it works fine until I clear a filter, the event fires but doesn't tell which event is fired.




.../api/items?filter1=value&filter2=value

Answer



I missed the below line and this was causing unexpected behavior. Instead of containing information about all the filters it was only showing information about the filter that was changed.



        ....
[filter]="filter"
....

>


Working demo - app.component.ts has the relevant code.
Changing the filters should log all the filters to the console.
https://embed.plnkr.co/Ymz4CSFVmXirnxCFlAeE/


No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...