我已经在jqGrid的两个问题
1)假设有91条记录表ROWNUM设置为10,现在,当我浏览到最后一页,并删除备案号91,它不会自动重新加载电网,当我使用ReloadGrid明确它去重新从整个数据控制器这增加了网络负载。
2)在我的网格有10页,当我输入页码比在文本框中最大页面越大它给人的空白格,理想的应该dispaly一些消息。
任何解决方案?
添加的代码FOR问题,更好地理解
$(document).ready(function () {
$('#jqgCars').jqGrid({
//url from wich data should be requested
url: '@Url.Action("CarsListing", "Car")?Carid=' + getID(),
//event for inline edit
onSelectRow: function (currentSelectedRow) {
if (currentSelectedRow && currentSelectedRow != $.lastSelectedRow) {
//save changes in row
$('#jqgCars').jqGrid('saveRow', $.lastSelectedRow, false);
$.lastSelectedRow = currentSelectedRow;
}
},
//type of data
datatype: 'json',
//url access method type
mtype: 'POST',
//columns names
colNames: ['ID','Number','Name'],
//columns model
colModel: [
{ name: 'ID', index: 'ID', align: 'left', editable: false },
{ name: 'Number', index: 'Number', align: 'left', editable: true, formatter: "text", edittype: 'text', editrules: { required: true}, editoptions:{maxlength:"25"}},
{ name: 'Name', index: 'Name', align: 'left', editable: true, formatter: "text", edittype: 'text', editrules: { required: false} , editoptions:{size:"35",maxlength:"255"}},
],
//pager for grid
pager: $('#jqgpCars'),
//number of rows per page
rowNum: 2,
//initial sorting column
sortname: 'name',
//initial sorting direction
sortorder: 'asc',
//display total records count
viewrecords: true,
//grid height
height: '100%'
});
$('#jqgCars').jqGrid('navGrid', '#jqgpCars', { add: true, del: true, edit: true, search: false });
$('#jqgCars').jqGrid('hideCol', "ID");
$('#jqgCars').setGridWidth(600 , true);
var dialogPosition = $(this).offset();
});
UPDATE -解决方案
问题的解决方案#1
$.extend($.jgrid.del, {
afterComplete: function () {
var p = $('#jqgCars')[0].p;
var newPage = p.page; // Gets the current page
if (p.reccount === 0 && newPage > p.lastpage && newPage > 1) {
// if after deleting there are no rows on the current page and lastpage != firstpage than
newPage--; // go to the previous page
}
// reload grid to make the row from the next page visable.
$(p.pager + " input.ui-pg-input").val(newPage); //Here setting the new page into textbox before loading in case of longer grid it would look nice
$('#jqgCars').trigger("reloadGrid", [{page: newPage}]); // reloading grid to previous page
}
});
问题#2解决方法是精确的张贴由奥列格
这正常工作与jqGrid的V4.1.2