What is the appropriate way to filter a grid using the knockout-kendo kendoGrid binding?
I am currently filtering a grid by binding it to a computed array, using the technique shown here: Utility Functions in KnockoutJS - see "Filtering an Array."
self.filteredItems = ko.dependentObservable(function() {
var filter = self.filter().toLowerCase();
if (!filter) {
return self.items();
} else {
return ko.utils.arrayFilter(self.items(), function(item) {
return item.name().toLowerCase().indexOf(filter) !== -1;
});
}
}, self);
This works, however if you are not on Page #1, it does not reset the grid to page #1, so if there are less "pages" of results than what your search ends up with, the grid will be blank until paged to page 1.
To see the issue, 1. go to this JSFIDDLE - http://jsfiddle.net/xW9yc/11/ 2. go to page 3 3. enter "P" in the search input