What is the best approach to load/filter/order a Kendo grid with the following classes:
Domain:
public class Car
{
public virtual in
Something about that seems weird. You told Kendo UI to make a grid for CarViewModel
.Grid()
and told it there is an IsActive
column:
columns.Bound(c => c.IsActive);
but CarViewModel
doesn't have a column by that name:
public class CarViewModel
{
public virtual int Id { get; set; }
public virtual string Name { get; set; }
public virtual string IsActiveText { get; set; }
}
My guess is that Kendo is passing up the field name from the CarViewModel IsActiveText
, but on the server you are running ToDataSourceResult()
against Car
objects (an IQueryable
), which do not have a property by that name. The mapping happens after the filtering & sorting.
If you want the filtering and sorting to happen in the database, then you would need to call .ToDataSourceResult()
on the IQueryable before it runs against the DB.
If you have already fetched all your Car
records out of the DB, then you can fix this by doing your mapping first, then calling .ToDataSourceResult()
on an IQueryable
.