グリッドの現在のページreccount
に番号またはレコードを提供するオプションを使用できます。レコード数が 0 の場合は、追加のアクションを実行できます。たとえば、追加のオプションでトリガーできます(回答を参照)reloadGrid
page
var $self = $(this), // or $("#gridId")
p = $self.jqGrid("getGridParam"), // get all parameters
newPage;
if (p.lastpage > 1) { // on the multipage grid
newPage = p.page; // the current page
if (p.reccount === 0 && p.page === p.lastpage) {
// if after deleting there are no rows on the current page
// which is the last page of the grid
newPage -= 1; // go to the previous page
}
// reload grid to show rows from the page with rows.
// depend on where you use the code fragment you could
// need reloading only in case
// p.reccount === 0 && p.page === p.lastpage
setTimeout(function () {
$self .trigger("reloadGrid", [{ page: newPage}]);
}, 50);
}
グリッド本体にメッセージ テキストを表示する必要がある場合は、回答用に作成されたデモに従うことができます。の場合、デモでは、メッセージ テキストを含む div のみが表示されます。reccount === 0