Kendo UI Grid可排序(和其他属性)不起作用 [英] Kendo UI Grid sortable (and other properties) not working

查看:375
本文介绍了Kendo UI Grid可排序(和其他属性)不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试配置Kendo网格,并且在尝试添加属性(例如排序,分组等)时遇到问题.网格在我添加属性之前一直有效,然后它不显示任何数据.我看过Kendo网站上的文档,看起来好像我拥有与他们相同的所有东西,但是显然我在弄些东西.

I'm trying to configure a Kendo grid and I'm having issues when trying to add properties such as sorting, grouping, etc. The grid works until I add the property, then it doesn't display any of the data. I have looked at the documentation on Kendo's site and it looks as if I have everything the same as theirs but obviously I'm nissing something.

这里是视图:

@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>

推荐答案

您尚未包含必需的JavaScript文件,并且JavaScript错误表示kendoSortable丢失.检查文档中所需的JavaScript文件: http://docs.kendoui.c​​om/getting-开始/javascript依赖项

You haven't included the required JavaScript files and the JavaScript error means that kendoSortable is missing. Check the documentation for the required JavaScript files: http://docs.kendoui.com/getting-started/javascript-dependencies

这篇关于Kendo UI Grid可排序(和其他属性)不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆