Quick project background: I am porting some Telerik for ASP.NET grids/back end data sources to Kendo angular UI framework.
Problem: I'm trying to implement grid filtering (has to be custom since I manually bind to handle complex paging/data retrieval.
if (filter !== undefined) {
// Step through column filters
filter.filters.forEach((element: any) => {
// console.log(element);
// Step through individual filter for column
element.filters.forEach((curFilter: any) => {
console.log(curFilter.field);
console.log(curFilter.operator);
console.log(curFilter.value);
});
});
}
I feel like I'm missing something here so I thought I'd start a conversation.
Thanks! -Brian
I believe based on your comment answer what you are attempting to do is get the filters and sorts, paging just like its sent for MVC on the network.
For kendo to do this you need to set your data source type and have the right file included in your page.
the file name is kendo.aspnetmvc.js or kendo.aspnetmvc.min.js
and your data source initialization should specify
dataSource: {
transport: {
type: 'aspnetmvc-ajax'
}
}
or do the same thing are they are doing
the cdn for this script is https://kendo.cdn.telerik.com/2018.1.221/js/kendo.aspnetmvc.min.js
I know they use the like of this functions to do what you are talking about
function serializeFilter(filter, encode) {
if (filter.filters) {
return $.map(filter.filters, function (f) {
var hasChildren = f.filters && f.filters.length > 1, result = serializeFilter(f, encode);
if (result && hasChildren) {
result = '(' + result + ')';
}
return result;
}).join('~' + filter.logic + '~');
}
if (filter.field) {
return filter.field + '~' + filter.operator + '~' + encodeFilterValue(filter.value, encode);
} else {
return undefined;
}
}