1

我正在尝试在我的 MVC3 应用程序中连接 Kendo UI 网格,但没有显示任何数据。我认为它应该很简单,但我没有看到它。这是我的代码:

看法:

@model List<pests.web.com.Models.Workitem>

@{
    ViewBag.Title = "Worklist";
    ViewBag.CurrentPage = "Worklist";
}

    <div id="grid"></div>

    <script type="text/javascript">
        $("#grid").kendoGrid({
            dataSource: {
                type: "json",
                transport: {
                    read: {
                        url: "Home/GetWorklist",
                        dataType: "json",
                        type: "POST",
                        contentType: "application/json; charset=utf-8",
                        data: {}
                    }
                },
                columns: [
            {
                field: "PartNumber",
                width: 90,
                title: "Part Number"
            },
            {
                field: "ProcurementCode",
                width: 90,
                title: "Procurement Code"
            },
            {
                width: 100,
                field: "Priority"
            },
            {
                field: "Status"
            }
            ]
            }
        });
    </script>


<script type="text/javascript" src="../../Scripts/people.js"></script>
<script type="text/javascript" src="../../Scripts/kendo.web.min.js"></script>
<script type="text/javascript" src="../../Scripts/console.js"></script>
<link href="../../Styles/kendo.common.min.css" rel="stylesheet" />
<link href="../../Styles/kendo.default.min.css" rel="stylesheet" />

布局页面:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>@ViewBag.Title</title>
    <link href="@Url.Content("~/Styles/Site.css")" rel="stylesheet" type="text/css" />
    <script src="@Url.Content("~/Scripts/jquery-1.5.1.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/modernizr-1.7.min.js")" type="text/javascript"></script>
</head>

    <body>

        @RenderBody()

    </body>
</html>

我试图从视图中调用的控制器代码:

 public class HomeController : Controller
    {
        [HttpPost]
        public ActionResult GetWorklist()
        {
            List<Workitem> worklist = PestsLogic.GetWorklist();
            return View("Home", worklist);
        }
    }

GetWorklist() 正在返回一些项目。它们是具有一些属性的简单对象。这是它:

public class Workitem
{
    public string PartNumber { get; set; }
    public string ProcurementCode { get; set; }
    public int Priority { get; set; }
    public string Status { get; set; }
}

有什么明显的地方我搞错了吗?没有错误消息,只有一个空白页(虽然有标题)。

谢谢!

4

1 回答 1

0

问题很简单,在我尝试使用剑道网格之前,我需要将 JS 文件的引用移动到。

于 2012-04-20T22:27:43.350 回答