I am using AngularJS along with KendoUI to create a grid, which gets its data from a WebAPI webservice. For the grid, I want to allow server-side sorting, paging, filtering, and grouping. For this purpose, I am trying to use the KendoGridBinderEx library.
I have downloaded the KendoGridBinderEx source, run the example project, and it works fine. However, when I do the exact same thing in my project, I get the following error when I try to do a filter on a column in the grid:
System.Linq.Dynamic.ParseException: No property or field 'test' exists in type 'MyEntity'
"test" is what I am typing into the filter, so it should be the filter text; it should not be looking for a property or field called "test".
I have debugged and used Fiddler to see that the filter part of the request being sent over in the request is exactly the same as the working request in the examples, so I don't think the problem is on the request side.
For all my code blocks, I am simplifying everything to save space, and to cut out things that are not relevant. For instance, I am cutting out my database code, and generating a list of entities on the fly, since doing so still exhibits the problem, hence I know that it is not a problem with my Entity Framework code.
Here is my JS code:
var myDataSource = {
transport: {
read: {
url: function () {
return url;
},
type: 'post',
dataType: 'json'
},
parameterMap: function (options, operation) {
if (options.filter) {
KendoGrid_FixFilter(myDataSource, options.filter);
}
if (operation === "read") {
// convert the parameters to a json object
return kendo.stringify(options);
}
return options;
}
},
serverPaging: true,
serverSorting: true,
serverFiltering: true,
serverGrouping: true
schema: {
data: 'data',
groups: 'groups',
aggregates: 'aggregates',
total: 'total',
model: {
id: "id",
fields: {
id: { type: "number" },
name: { type: "string" },
description: { type: "string" }
}
}
},
};
And here is my WebAPI Controller code:
[System.Web.Http.Route("api/MyEntity")]
[System.Web.Http.HttpPost]
public KendoGridEx<MyEntity, MyEntity> GetMyEntities(KendoGridApiRequest request)
{
var entList = new List<MyEntity>();
for (int i = 0; i < 10; i++)
{
var newEntity = new MyEntity
{
Id = i,
Name = "test",
Description = "description"
};
entList.Add(newEntity);
}
return entList.AsQueryable().ToKendoGridEx<MyEntity, MyEntity>(request);
}
So if I set a "contains" filter on the "Name" column with a value of "test" I get the above-mentioned error. Any ideas as to why?