<ul data-role="listview" id="tabletDrawer" data-click="drawerClick"> <li> <a href="views/oc.html" data-icon="fa-calculator">Order Calculator</a> </li> <li> <a href="views/oc.html" data-icon="fa-refresh">Reset</a> </li> <li> <a href="views/settings.html" data-icon="spc-settings">Settings</a> </li> <li> <a href="#logView" data-icon="spc-log">Log</a> </li> <li> <a href="skunkworks.html" data-icon="spc-settings">IT Development Area</a> </li> <li> <a href="debug.html" data-icon="spc-settings" class="spc-debug">IT Debug Info</a> </li></ul>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>{"GetRequestSummaryRestResult":"{\"Data\":[{\"Id\":0.0,\"RequestId\":121.0,\"Creator\":\"Elmer Fudd\",\"Recipient\":\"Bugs Bunny\",\"Assignee\":null,\"RequestType\":\"EquipmentLoan\",\"Description\":\"Mobile phone with the Android operating system\",\"CreationDate\":\"2015-01-14T10:45:09\",\"Status\":null,\"Comments\":null},{\"Id\":1.0,\"RequestId\":2.0,\"Creator\":\"Porky Pig\",\"Recipient\":\"Tweety Pie\",\"Assignee\":null,\"RequestType\":\"EquipmentAcquisition\",\"Description\":\"Holds the laptop at eye height\",\"CreationDate\":\"2014-06-03T11:27:38\",\"Status\":null,\"Comments\":\"me has\"}],\"Total\":11}"}. For some reason the Data and Total are wrapped in an object that is the name of the WCF Service method plus the word Result. I have gotten around it by adding the following to the schema part of the datasource definition:
schema: {
data: function (data)
{
return jQuery.parseJSON(data.GetRequestSummaryRestResult).Data;
},
total: function (data)
{
return jQuery.parseJSON(data.GetRequestSummaryRestResult).Total;
},
model: requestsummary
},
Is this the expected behaviour and is my solution the best way to deal with it? Please let me know.