I have a grid bound to a simple object. There are no Ajax calls. It's all set at init.
My Object: Account with properties Name and an Array of Tag strings. Real simple.
I pass in an array of tags into this function and need the dataSource to filter the grid. How is that done?
function filterGridResults(tags) {
var grid = $("#gridAccounts").data("kendoGrid");
var dataSource = grid.dataSource;
//??? filter document.Tags
}
If I understand you correctly you are binding your grid to local data. If so then this should solve your problem:
function filterGridResults(tags) {
var grid = $("#gridAccounts").data("kendoGrid");
var dataSource = grid.dataSource;
var filterField = "Tag";//This is the object field you will filter by
var filterOperator = "contains";//How you will filter
var filterValue = tags;//What your filter value will be
dataSource.filter(
{
field: filterField,
operator: filterOperator ,
value: filterValue
});
}
Hope this answers your question!