在 JQGrid 分页上需要帮助。下面是一段代码,
错误线:var currentPage = $('#gridData').getGridParam('page');
ERR MSG : 0x800a01b6
- microsoft jscript 运行时错误对象不支持此属性或方法。
我也检查了 Jquery 参考资料。一切都很好。不知道哪里出错了:(
$("#gridData").jqGrid({
data: selectedTblData.Table.Rows,
datatype: "local",
toppager: true,
height: "100%",
width: (selectedTblData.Table.Width < 1000) ? 985 : "100%",
altRows: true,
altclass: "custom-alt-row",
colNames: selectedTblData.Table.colNames,
colModel: selectedTblData.Table.colModel,
multiselect: false,
rowNum: 25,
rowList: [15, 25, 50, 75, 100],
mtype: 'GET',
pager: '#pager',
sortname: selectedTblData.Table.colNames[0],
sortorder: "asc",
viewrecords: true,
shrinkToFit: (selectedTblData.Table.Width < 1000),
caption: tableName,
secureUri: false,
contentType: "application/json; charset=utf-8",
loadonce: true,
//BS Page start
onPaging: function (pgButton) {
//debugger;
var pagerId = this.p.pager.substr(1); // get paper id like "pager"
var currentPage = $('#gridData').getGridParam('page'); //get current page
var lastPage = $("#gridData").getGridParam("lastpage"); //get last page
if (currentPage - 1 == lastPage - 1)
$("#gridData").setGridParam({ page: lastPage }).trigger("reloadGrid"); // set the requested page to the last page value – then reload
var currentRecordCount = $("#gridData").getGridParam("reccount"); //get the record count
var recordsPerPage = $("#gridData").getGridParam("rowNum"); // get the records per page
var newValue = 0; // new value
if (pgButton === "user") {
newValue = $(".ui-pg-input").val();
}
else {
if (pgButton.indexOf("next") >= 0)
newValue = ++currentPage;
else if (pgButton.indexOf("prev") >= 0)
newValue = --currentPage;
else if (pgButton.indexOf("last") >= 0)
newValue = $("#gridId").getGridParam('lastpage');
else if (pgButton.indexOf("first") >= 0)
newValue = 1;
}
alert(newValue);
$("#gridData").setGridParam({ page: newValue }).trigger("reloadGrid"); // set the requested page to the last page value – then reload
currentRecordCount = $("#gridData").getGridParam("reccount"); // read the current page records
alert('RecordCount: ' + currentRecordCount + ' RecordsPerPage: ' + recordsPerPage);
if (currentRecordCount < recordsPerPage) {
startRange = 1;
endRange += endRange;
jQuery("#gridData").jqGrid("setGridParam", { datatype: "json", data: "{TableName :'" + tableName + "'}", url: "TablesCoolView.aspx/GetTableData" }).trigger("reloadGrid");
}
}
//BS page end
});