I need help returning Json data back and populating a very simple grid, here is my code:
Model:
public class CapitalLeaseCostModel
{
public int ID { get; set; }
public string Reasons { get; set; }
public CapitalLeaseCostModel()
{
}
}
View:
<
script
>
$(document).ready(function () {
var crudServiceBaseUrl = "//demos.telerik.com/kendo-ui/service",
dataSource = new kendo.data.DataSource({
transport: {
read: {
url: "/CapitalLease/Costs_Read",
dataType: "json"
},
parameterMap: function (options, operation) {
if (operation !== "read" && options.models) {
return { models: kendo.stringify(options.models) };
}
}
},
batch: true,
pageSize: 20,
schema: {
model: {
id: "ID",
fields: {
ID: { editable: false, nullable: true },
Reasons: { type: "text" }
}
}
}
});
$("#capitalizedCostGrid").kendoGrid({
dataSource: dataSource,
pageable: true,
height: 550,
toolbar: ["create"],
columns: [
{ field: "ID", title: "ID" },
{ field: "Reasons", title: "Reasons" }],
editable: "inline"
});
});
</
script
>
@*Rent Information*@
<
p
class
=
"title"
>Section Two - Lease Costs to Capitalize</
p
>
<
div
style
=
"padding:15px;"
>
<
div
id
=
"costsRowOne"
>
<
div
id
=
"capitalizedCostGrid"
class
=
"inline-control"
></
div
>
</
div
>
</
div
>
Controller:
[AcceptVerbs(HttpVerbs.Get)]
public JsonResult Costs_Read()
{
CapitalLeaseCostModel testModel = new CapitalLeaseCostModel();
testModel.ID = 1;
testModel.Reasons = "test reason1";
List<
CapitalLeaseCostModel
> list = new List<
CapitalLeaseCostModel
>();
list.Add(testModel);
return Json(JsonConvert.SerializeObject(list), JsonRequestBehavior.AllowGet); ;
}
The grid loads fine but now data. What am I missing? This is based off of the inline-editing demo for kendo-ui.
Thanks