@(Html.Kendo()
.ListView<
ReportTypeViewModel
>()
.Name("listView")
.TagName("ul")
.DataSource(ds => ds.Read(read => read.Url("/api/ReportApi/List").Type(HttpVerbs.Get)))
.ClientTemplateId("templateReportList"))
When I pass list to the constructor by:
.ListView<
ReportTypeViewModel
>(types)
Url
"/api/ReportApi/List"
is MVC 4 web api.However when I checked not MVC version of list the following code works:
function initList() {
$("#listview").kendoMobileListView({
template: "<
a
><
span
>${data.Name}</
span
></
a
>",
dataSource: new kendo.data.DataSource({
transport: {
read: "/api/ReportApi/List",
type: "json"
},
}),
style: "inset"
});
}
UPDATE:
I've posted this in wrong thread - could you please move it to proper one?
10 Answers, 1 is accepted
The Kendo MVC ListView expects the data to be returned in an object with Data as name. For example:
return
new
DataSourceResult()
{
Data = myData
};
Regards,
Daniel
the Telerik team
I am not sure if I understand correctly the problem with the result. Is there no control over the returned data?
As general information I can say that the ListView wrapper is intended for use with the MVC controllers and the DataSourceResult like described in the ListView Binding documentation topic.
Daniel
the Telerik team
The reason why the MVC ListView as well as the Grid require a different result is that they support server paging and need information about the total number of records. The Chart always loads all the data on the client so it can accept a simple JSON array.
Regards,Daniel
the Telerik team
Here is a simple example of a method on a controller that does this from the MVC Examples project:
public
ActionResult Products_Read([DataSourceRequest] DataSourceRequest request)
{
return
Json(GetProducts().ToDataSourceResult(request));
}
About your answer:
a) this is not solution for me since I'm using web api (MVC 4), that ia available for many application. So changing result of web api by creating wrapper to use wrapper has totally no sense for me.
b) like I written before I can use result from my web api (MVC 4) without changing anything in native kendo javascript ListView (see my first post), and in fact I didn't receive any explanation why I can use this in java script ListView, but wprapper which on output creates such java script represenation can not use such api.
c) You are saying that listview requires special type which contains Data field. But this is not true, becuase I can use list without such special data when I'm not using wrapper.
The wrappers are designed to use the Kendo MVC server API and therefore have some predefined options set. The reason why the Data and Total fields are needed in the response, is that the schema data and total are set:
schema:{
data:
"Data"
,
total:
"Total"
Daniel
the Telerik team
Now I understand.