jqGrid afterclickPgButtons 跳过 isLeaf non is TRUE 的行?

jqGrid afterclickPgButtons skip the line where isLeaf non is TRUE?

我使用 jqGrid 4.9.3-pre - Oleg 免费的 jqGrid。

我使用:

代码

treeGrid:true,
ExpandColumn:'name',
treedatatype:"json",
treeGridModel:"adjacency",
treeReader:{
   level_field: "level",
   parent_id_field: "parent",
   leaf_field: "isLeaf",
   expanded_field: "expanded",
   loaded:true,
},
loadonce: false

如何 If isLeaf is TRUE 跳过该行并转到 isLeaf non 为 TRUE 的下一行?

编辑表单的导航按钮没有特殊的界面,可以允许跳过一些行,但是可以使用 onclickPgButtons 来防止导航到 next/previous 行并模拟点击之后立即按相同的按钮。了解 jqGrid 在带有 id="id_g" 的表单中包含隐藏字段很重要,它将被表单编辑用作 current 编辑行的 rowid。因此可以在 click.

的 模拟之前更改隐藏字段的值

onclickPgButtons 回调的对应实现如下:

onclickPgButtons: function (buttonName, $form, rowid) {
    var $self = $(this),
        iRow = $self.jqGrid("getGridRowById", rowid).rowIndex,
        isLeaf = $self.jqGrid("getGridParam", "treeReader").leaf_field,
        rows = this.rows,
        nRows = rows.length,
        iInc = buttonName === "next" ? 1 : -1,
        isNextRowVisibleLeaf = function () { // iRow - the current row
            var $nextRow = $(rows[iRow + iInc]),
                rowidNext = $nextRow.attr("id");
            if (rowidNext != null) {
                var nextItem = $self.jqGrid("getLocalRow", rowidNext);
                if (nextItem != null && nextItem[isLeaf] && $nextRow.css("display") !== "none") {
                    return true;
                }
            }
            return false;
        },
        $button = $(buttonName === "next" ? "#nData" : "#pData");

    if (isNextRowVisibleLeaf()) {
        return true; // nothing to do
    }
    // we need to fix the row, which the next row is visible leaf
    while (iRow < nRows && iRow > 0) {
        iRow += iInc;
        if (isNextRowVisibleLeaf()) {
            // set the value of hidden field of the form
            // to the id of the found row and simulate the click
            // on the same navigation button
            $form.find("#id_g").val($(rows[iRow]).attr("id"));
            setTimeout(function () {
                $button.click();
            }, 50);
            return false;
        }
    }
    return false;
}

the demo