我正在尝试配置一个Kendo网格,并且在尝试添加排序,分组等属性时遇到问题。网格一直有效,直到我添加属性,然后它才显示任何数据。我查看了剑道网站上的文档,看起来好像我的一切都和他们的一样,但显然我有点麻烦。
以下是视图:
@model ExampleKendoUI.Models.HeaderVm
@{
ViewBag.Title = "Index";
}
<h2>Index</h2>
<div>@Model.Name</div>
@section scripts {
<script>
// Output the data as JSON
var podata = @Html.Raw(Json.Encode(ViewBag.LineItems));
</script>
<div id="poGrid" class="k-content">
<script>
$(document).ready(function () {
$("#poGrid").kendoGrid({
dataSource: {
data: podata
},
// sortable:true, *** Uncommenting this will break the grid ***
columns: [
{
field: "Description",
title: "Desc"
},
{
field: "Quantity",
title: "Quantity"
}
]
});
});
</script>
</div>
}
这是控制器:
namespace ExampleKendoUI.Controllers
{
public class SampleController : Controller
{
//
// GET: /Sample/
public ActionResult Index(int id)
{
var header = new HeaderVm()
{
Id = id,
Name = "Req ID"
};
var results = new List<PoLineVm>()
{
new PoLineVm()
{
Id = 1,
Description = "Some Product",
Quantity = 1.5
},
new PoLineVm()
{
Id = 2,
Description = "Another Product",
Quantity = 4.0
},
new PoLineVm()
{
Id = 3,
Description = "Last Product",
Quantity = 20
},
};
ViewBag.LineItems = results;
return View(header);
}}}
这是_Layout:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>@ViewBag.Title</title>
@Styles.Render("~/Content/css")
<link href="~/Content/kendo/2012.3.1114/kendo.default.min.css" rel="stylesheet" />
@Scripts.Render("~/bundles/modernizr")
</head>
<body>
@RenderBody()
@Scripts.Render("~/bundles/jquery")
<script src="/scripts/kendo/2012.3.1114/kendo.core.min.js"></script>
<script src="~/Scripts/kendo/2012.3.1114/kendo.data.min.js"></script>
<script src="~/Scripts/kendo/2012.3.1114/kendo.grid.min.js"></script>
@RenderSection("scripts", required: false)
</body>
</html>
答案 0 :(得分:1)
您还没有包含所需的JavaScript文件,JavaScript错误意味着缺少kendoSortable。查看文档以获取所需的JavaScript文件:http://docs.kendoui.com/getting-started/javascript-dependencies