I've been struggling to get OData results to show up in Kendo Grid without luck. Even when I would get the endpoint returning a JSON result set, the grid still would fail to display any records. I can also save new records, although the grid gets back a 406 message and does not realize the record was successfully saved.
If I could just find an example of an OData v4 service project that works with Kendo Grid I'm pretty sure I could figure this out. Anyone?
public class ListController<TObject> : ApiController where TObject : class, IListItem{ [Queryable] public IEnumerable<TObject> Get() { var results = _repository.GetAll(); return results.AsEnumerable(); }public static class WebApiConfig{ public static void Register(HttpConfiguration config) { // Web API configuration and services var cors = new EnableCorsAttribute("*", "*", "*"); config.EnableCors(cors); config.EnableCaseInsensitive(true); config.Formatters.JsonFormatter.SerializerSettings.PreserveReferencesHandling = Newtonsoft.Json.PreserveReferencesHandling.All; // Web API routes config.MapHttpAttributeRoutes(); //config.Routes.MapHttpRoute( // name: "DefaultApi", // routeTemplate: "api/{controller}/{id}", // defaults: new { id = RouteParameter.Optional } //); ODataModelBuilder builder = new ODataConventionModelBuilder(); builder.EntitySet<LotStatus>("lotstatuses"); config.MapODataServiceRoute( routeName: "odata", routePrefix: "", model: builder.GetEdmModel()); }}<script> var remoteDataSource = new kendo.data.DataSource({ batch: false, serverPaging: true, serverSorting: true, serverFiltering: true, type: "odata", transport: { read: { url: "http://localhost:55097/lotstatuses", dataType: "json", //contentType: "application/json" }, create: { url: "http://localhost:55097/lotstatuses", dataType: "json", contentType: "application/json", type: "POST" }, update: { url: "http://localhost:55097/lotstatuses", dataType: "json", contentType: "application/json", type: "PUT" }, destroy: { url: "http://localhost:55097/lotstatuses", dataType: "json", contentType: "application/json", type: "DELETE" }, parameterMap: function (options, operation) { var paramMap = kendo.data.transports.odata.parameterMap(options); delete paramMap.$inlinecount; // <-- remove inlinecount parameter delete paramMap.$format; // <-- remove format parameter return paramMap; } }, schema: { data: function (data) { return data.value; }, total: function (data) { return data["odata.count"]; }, errors: function (data) { }, model: { id: "Code", fields: { Code: { type: "string", editable: true, nullable: false, validation: { required: true } }, Name: { type: "string", editable: true, nullable: false, validation: { required: true } } } } } }); $('#grid').kendoGrid({ dataSource: remoteDataSource, height: 500, toolbar: [{ name: "create", text: "Create new Lot Status" }], filterable: true, sortable: true, pageable: true, editable: "popup", columns: [ { field: "Code", title: "Code" }, { field: "Name", title: "Name" }, { command: ["edit", "destroy"] } ] });</script>If I could just find an example of an OData v4 service project that works with Kendo Grid I'm pretty sure I could figure this out. Anyone?