如果jqgrid在某个时间没有行,则会显示Page 1 of NaN
这里的Nan
是什么?我们不能把它改成更合适的东西,如Page 0 of 0
或更好的东西吗?
我的jqgrid代码
var grid = jQuery("#list1");
grid.jqGrid({
datastr : xml,
datatype: 'xmlstring',
colNames:['cfgId','Name', 'Host', 'Description','Product', 'Type', 'Last Updated Time','Last Updated By','',''],
colModel:[
{name:'cfgId',index:'cfgId', width:90, align:"left", hidden:true},
{name:'cfgName',index:'cfgName', width:90, align:"left", formatter: 'showlink', formatoptions:
{
baseLinkUrl:'javascript:',
showAction: "goToViewAllPage('",
addParam: "');"
}},
{name:'hostname',index:'hostname', width:90, align:"left"},
{name:'cfgDesc',index:'cfgDesc', width:90, align:"left"},
{name:'productId',index:'productId', width:60, align:"left"},
{name:'cfgType',index:'cfgType', width:60, align:"left"},
{name:'updateDate',index:'updateDate',sorttype:'Date', width:120, align:"left"},
{name:'emailAddress',index:'emailAddress', width:120, align:"left"},
{name:'absolutePath',index:'absolutePath', width:90, align:"left", hidden:true},
{name:'fileName',index:'fileName', width:90, align:"left", hidden:true},
],
pager : '#gridpager',
rowNum:10,
rowList:[10,50,100],
scrollOffset:0,
height: 'auto',
emptyrecords: 'No configurations loaded',
autowidth:true,
viewrecords: true,
gridview: true,
multiselect: true,
xmlReader: {
root : "list",
row: "Response",
userdata: "userdata",
repeatitems: false
},
loadComplete: function () {
var count = grid.getGridParam();
var ts = grid[0];
if (ts.p.reccount === 0) {
grid.hide();
emptyMsgDiv.show();
} else {
grid.show();
emptyMsgDiv.hide();
}
},
onSelectRow: function(id,status){
var rowData = jQuery(this).getRowData(id);
configid = rowData['cfgId'];
configname=rowData['cfgName'];
configdesc=rowData['cfgDesc'];
configenv=rowData['cfgType'];
absolutepath=rowData['absolutePath'];
/*filename=rowData['fileName'];
updatedate=rowData['updateDate'];
absolutepath=rowData['absolutePath'];*/
updateproductid=rowData['productId'];
$('#cfgid').removeAttr('disabled');
document.getElementById("cfgid").value=configid;
document.getElementById("cfgname").value=configname;
document.getElementById("cfgdesc").value=configdesc;
var element = document.getElementById('cfgenv');
if(configenv=="Production")
element.value = "Production";
else if(configenv=="Development")
element.value="Development";
else
element.value="Test/QA";
rowChecked=1;
currentrow=id;
}
});
grid.jqGrid('navGrid','#gridpager',{edit:false,add:false,del:false});
jQuery("#m1").click( function() {
var s;
s = grid.jqGrid('getGridParam','selarrrow');
alert(s);
});
var myGrid = $("#list1");
$("#cb_"+myGrid[0].id).hide();
// place div with empty message insde of bdiv
emptyMsgDiv.insertAfter(grid.parent());
}
我的Xml
<Response>
<isSuccess>true</isSuccess>
<operation>viewall</operation>
<message>No configurations were found for this project</message>
</Response>
答案 0 :(得分:2)
与here描述的问题相同,但是使用XML数据。
在the line中,将声明变量rn
,但不会为其分配任何值。值rn = parseInt(ts.p.rowNum,10);
的第一个分配将在if(gxml && gl)
内here,在您的情况下为false
。所以the statement
ts.p.lastpage = Math.ceil(gl/ rn);
产生NaN
值。
要解决此问题,您可以修改jqGrid 4.1.2 jquery.jqGrid.src.js
的第1086行
var gl = gxml.length, j=0, grpdata={}, rn;
到
var gl = gxml.length, j=0, grpdata={}, rn = parseInt(ts.p.rowNum,10);
可以删除包含相同作业的第1088行。
如何在the demo中看到(与your same code使用的原始jquery.jqGrid.src.js
相比),这些更改可以解决问题。