C# jqgrid不显示行
我使用此链接构建了一个基本的jqgrid: 这是我的代码:C# jqgrid不显示行,c#,jquery,asp.net-mvc-2,C#,Jquery,Asp.net Mvc 2,我使用此链接构建了一个基本的jqgrid: 这是我的代码: <script type="text/javascript"> jQuery(document).ready(function () { jQuery("#list").jqGrid({ url: '/Home/GridData/', datatype: 'json', mtype: 'GET', colNames: ['ProductID', 'Pr
<script type="text/javascript">
jQuery(document).ready(function () {
jQuery("#list").jqGrid({
url: '/Home/GridData/',
datatype: 'json',
mtype: 'GET',
colNames: ['ProductID', 'ProductName'],
colModel: [
{ name: 'ProductID', index: 'ProductID', width: 40, align: 'left' },
{ name: 'ProductName', index: 'ProductName', width: 40, align: 'left'}],
pager: jQuery('#pager'),
rowNum: 10,
rowList: [5, 10, 20, 50],
sortname: 'Id',
sortorder: "desc",
viewrecords: true,
imgpath: '/scripts/themes/coffee/images',
caption: 'My first grid'
});
});
你看过你链接的全部帖子了吗?他返回的json看起来与您返回的json大不相同
public ActionResult GridData(string sidx, string sord, int page, int rows) {
var jsonData = new {
total = 1, // we'll implement later
page = page,
records = 3, // implement later
rows = new[]{
new {id = 1, cell = new[] {"1", "-7", "Is this a good question?"}},
new {id = 2, cell = new[] {"2", "15", "Is this a blatant ripoff?"}},
new {id = 3, cell = new[] {"3", "23", "Why is the sky blue?"}}
}
};
return Json(jsonData, JsonRequestBehavior.AllowGet);
}
id字段很重要,jsgrid希望知道要添加的行号
public ActionResult GridData(string sidx, string sord, int page, int rows) {
var jsonData = new {
total = 1, // we'll implement later
page = page,
records = 3, // implement later
rows = new[]{
new {id = 1, cell = new[] {"1", "-7", "Is this a good question?"}},
new {id = 2, cell = new[] {"2", "15", "Is this a blatant ripoff?"}},
new {id = 3, cell = new[] {"3", "23", "Why is the sky blue?"}}
}
};
return Json(jsonData, JsonRequestBehavior.AllowGet);
}