我用json字符串创建一个jqgrid。就在一小时之前它正常工作。现在它不工作我不明白错误。它也没有显示任何错误消息。
public void ProcessRequest(HttpContext context)
{
string value = "{\"Table\":[{\"FLD_ID\":1,\"FLD_DATE\":\"17-02-2014 04:51:34 PM\",\"FLD_MOD_DATE\":\"17-02-2014 04:51:43 PM\",\"FLD_CNTRY_NAME\":\"DAFEDA\",\"FLD_CNTRY_CODE\":null,\"FLD_DESC\":\"VALUE\",\"FLD_STATUS\":1,\"CREATED_BY\":\"DAFEDA\"}],\"Table1\":[{\"DBSTATUS\":\"SUCCESS\"}]}";
context.Response.Write(value);
}
<script type="text/javascript">
try {
jQuery.fn.center = function () {
this.css("position", "absolute");
this.css("top", ($(window).height() - this.height()) / 2 + $(window).scrollTop() + "px");
this.css("left", ($(window).width() - this.width()) / 2 + $(window).scrollLeft() + "px");
return this;
}
var gwdth = $("#grd").width();
jQuery("#JQCntryGrid").jqGrid({
url: 'JQGridHandler.ashx',
datatype: "json",
width: gwdth,
height: 'auto',
colNames: ['Id', 'Date', 'Mod Date', 'Country Name', 'Country Code', 'Desc', 'Status', 'Created By'],
colModel: [
{ name: 'FLD_ID', index: 'FLD_ID', width: 20, stype: 'text' },
{ name: 'FLD_DATE', index: 'FLD_DATE', width: 150, stype: 'text', sortable: true, editable: false },
{ name: 'FLD_MOD_DATE', index: 'FLD_MOD_DATE', width: 60, editable: false },
{ name: 'FLD_CNTRY_NAME', index: 'FLD_USER_NAME', width: 150, editable: true, edittype: "text", editrules: { required: true} },
{ name: 'FLD_CNTRY_CODE', index: 'FLD_CNTRY_CODE', width: 120, editable: true, edittype: "text", editrules: { required: true} },
{ name: 'FLD_DESC', index: 'FLD_DESC', width: 130, editable: true, edittype: "text", editrules: { required: true} },
{ name: 'FLD_STATUS', index: 'FLD_STATUS', width: 100, editable: true, edittype: "select", editrules: { required: true} },
{ name: 'CREATED_BY', index: 'CREATED_BY', width: 130, sortable: true, editable: false },
],......
答案 0 :(得分:3)
您需要使用jsonReader
添加root: "Table"
来解决问题:
jsonReader: {
root: "Table",
repeatitems: false
},
我建议您另外使用loadonce: true
,gridview: true
,autoencode: true
选项(请参阅文档)。 width
的设置可能会被autowidth: true
的使用替换。
The demo演示了结果。