I am using a Kendo UI Grid in a ASP.Net MVC5 application and set up a column so that when you go to filter on it it queries the database for the unique results. I define the column like this:
col.Filterable(x => x.Multi(true).Search(true).DataSource(ds => ds.Read(r => r.Action("UniqueColumn", "Workbook").Data("filterUniquenessColumn()").Type(HttpVerbs.Post)).ServerFiltering(true)));
This only calls the controller the first time you go to it because it's cached. To get around this I subscribed to the ColumnMenuInit event and added the following code:
var menu = e.container.find(".k-menu").data("kendoMenu");
menu.bind('open', function (ex) {
if ($(ex.item).find('span.k-i-filter').length > 0) {
var filterMultiCheck = e.container.find(".k-filterable").data("kendoFilterMultiCheck");
if (filterMultiCheck) {
if ($('#grid').data('kendoGrid').dataSource.filter() !== undefined) {
var grid = $('#grid').data('kendoGrid');
filterMultiCheck.checkSource.transport.options.read.data.filter = grid.dataSource.filter();
filterMultiCheck.checkSource.options.type = 'aspnetmvc-ajax';
}
filterMultiCheck.checkSource.read();
}
}
});
This calls the controller every time they go to filter (which is what I want). The problem I am having is that on the controller side I am unable to get the Filters value of the [DataSourceRequest] DataSourceRequest request to be populated with the filters that are applied to the main grid. The result for Filters is always null. This is what my controller method looks like:
public ActionResult UniqueColumn([DataSourceRequest] DataSourceRequest request)
Does anyone know how I can get the filters property of the request to be populated? I put a trace on the network and the following is being passed via the url:
filter%5Bfilters%5D%5B0%5D%5Bfield%5D: PCode filter%5Bfilters%5D%5B0%5D%5Boperator%5D: eq filter%5Bfilters%5D%5B0%5D%5Bvalue%5D: 00090h4210 filter%5Blogic%5D: and
If anyone could tell me how to get the filters on the controller it would be greatly appreciated.
Thanks in advance.