I am using jqGrid by Trirand. The grid headers, rows, paging is displayed correctly but the data rows are not populated. I have gone through many posts and tried many solutions, but it simply won't work. I'm sure there some thing very simple that is missing but I am unable to figure it out.
I am getting the following response from my ASP.NET MVC Controller:
{ "total":1, "page":1, "records":2, "rows": [ { "Id":"1", "StudentName":"Student1" }, { "Id":"2", "StudentName":"Student2" } ] }
And the jqGrid code is as follows:
$(function () { $("#jqGrid").jqGrid({ url: '/Home/GetStudentsLists', dataType: "json", mtype: 'GET', colNames: ['Id', 'StudentName'], colModel: [ { name: 'Id', index: 'Id', width: 60 }, { name: 'StudentName', index: 'StudentName', width: 60 } ], rowNum: 9999, sortname: 'Id', loadonce: true, rowList: [10, 20, 30], pager: '#jqpager', viewrecords: true, sortorder: "desc", caption: "Students Details", height: 100, autowidth: true }) });
and the Layout page that contains the script tags looks like following:
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>@ViewBag.Title - My ASP.NET Application</title>
@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/modernizr")
</head>
<body>
...
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/bootstrap")
@RenderSection("scripts", required: false)
<link href="~/Content/themes/base/jquery-ui.css" rel="stylesheet" />
<link href="~/Content/jquery.jqGrid/ui.jqgrid.css" rel="stylesheet" />
<script src="~/Scripts/jquery-ui-1.10.0.js"></script>
<script src="~/Scripts/i18n/grid.locale-en.js"></script>
<script src="~/Scripts/jquery.jqGrid.js"></script>
<script src="~/Scripts/Custom/jQGridStudents.js"></script>
</body>
I appreciate your help.
dataType: "json"todatatype: "json". It should be your main problem. Other recommendation in your code would depend on the version and fork of jqGrid, which you use. - Olegdatatypeis not the same asdataType(with capicalT). The version 4.4.4 is 4.5 years old and it's dead since a long time. If you use NuGet, then I recommend you uninstall old packge and to use free-jqGrid. Alternatively I recommend you to consider to load free jqGrid from CDN. See here and here. - Oleg