【发布时间】:2020-04-10 22:32:22
【问题描述】:
我正在尝试使用 jqGrid。网格正在出现,但后端值没有绑定到网格中。行显示为空白。
只有两行来自后端。行生成正确,分页正确,但列中的值未绑定。
当我要检查时,只有 &nbps 存在。
提前致谢。
<script>
$(function () {
debugger;
$("#grid").jqGrid
({
url: "/client/GetAllClient",
datatype: 'json',
mtype: 'Get',
//table header name
colNames: ['Id', 'Client ID'],
//colModel takes the data from controller and binds to grid
colModel: [
{
key: true,
hidden: true,
name: 'Id',
index: 'Id',
editable: true
}, {
key: false,
name: 'ClientID',
index: 'ClientID',
editable: true
}],
pager: jQuery('#pager'),
rowNum: 10,
rowList: [10, 20, 30, 40],
height: '100%',
viewrecords: true,
caption: 'Jq grid sample Application',
emptyrecords: 'No records to display',
jsonReader:
{
root: "rows",
page: "page",
total: "total",
records: "records",
repeatitems: false,
Id: "0"
},
autowidth: true,
multiselect: false
//pager-you have to choose here what icons should appear at the bottom
//like edit,create,delete icons
}).navGrid('#pager',
{
edit: true,
add: true,
del: true,
search: false,
refresh: true
});
});
</script>
<table id="grid"></table>
<div id="pager"></div>
这是我的代码---
var Results = _objModel.Select(x => new
{
x.ClientID
});
var jsonData = new
{
total = totalPages,
page,
records = totalRecords,
rows = Results
};
return Json(jsonData);
【问题讨论】:
标签: c# jquery asp.net-mvc jqgrid mvcjqgrid