JqG​​rid数据无法查看

时间:2013-04-10 08:06:58

标签: jqgrid jqgrid-asp.net mvcjqgrid

我想在jqgrid中显示数据,但数据未显示 我的控制器代码在

之下
 public JsonResult getjqgriddata()
    {

        var emp=from v in ent.employees select v;
     var    users = emp.ToArray();

       return Json(users, JsonRequestBehavior.AllowGet);
    }

我的观看代码位于

之下
    <link  rel="stylesheet" href="~/Content/ui.jqgrid.css"  type="text/css"/>
@*<script src="http://code.jquery.com/jquery-1.6.2.min.js"></script>*@
<script src="~/Scripts/jquery-1.7.1.min.js"></script>
<script src="~/Scripts/grid.locale-en.js" type="text/javascript"></script>
<script src="~/Scripts/jquery.jqGrid.min.js" type="text/javascript"></script>
<script>
    $(document).ready(function () {

        $("#jqTable").jqGrid({
            url: "/HelloWorld/getjqgriddata",
            datatype: "json",
            mtype: "get",

            colNames: ["FirstName", "Id", "LastName", "Phone"],
            colModel: [
                 { name: "FirstName", Index: "FirstName", width: "40px", align: "left" },
                  { name: "Id", Index: "Id", width: "40px", align: "left" },
                  { name: "LastName", Index: "LastName", width: "40px", align: "left" },
                   { name: "Phone", Index: "Phone", width: "40px", align: "left" } ],
            width: 550,
            height: 200,
            rowNum: 1,
            jsonReader: { repeatitems: false, root: function (obj) { return obj; } },
            gridview: true,





            viewrecords: true, // Specify if "total number of records" is displayed

        });


    });





</script>



<div>
        <table id="jqTable" class="scroll"></table>
        <div id="jqTablePager" />
    </div>

我想知道当从控制器发送 json res 时,视图中查看数据的方式 请提前帮助谢谢

1 个答案:

答案 0 :(得分:0)

您必须以特定格式从操作方法返回json数据。有关更多详细信息,请参阅以下链接:

jqgrid in asp.net using json datatype