0

如果我使用这个:

loadComplete: rowCount() 

它不工作。
如果我们直接打电话,我想知道为什么它不起作用的原因。

代码片段:

function rowCount() {
    var recCount = $("#fbDetailTable").jqGrid('getGridParam', 'records');
    if (recCount == 0) {
        displayMessage("Freight bill not found");
    } else {
        displayMessage("Freight bill found");
    }
}

function getFreightBill() {
    var frtBill = document.getElementById("freightBill").value;
    if (isNaN(frtBill)) {
        displayMessage("Freight bill contain digits alone");
    } else {
        var intTemplate = {
            sorttype: "integer",
            formatter: "text",
            align: "center"
        };
        var dateTemplate = {
            sorttype: "date",
            formatter: "date",
            align: "center"
        };
        $("#fbDetailTable").jqGrid('GridUnload');
        $("#fbDetailTable").jqGrid({
            url: "/BSNReportBatch/rs/FBService/getFB?fB=" + frtBill,
            datatype: "json",
            colNames: ["Store Number", "Order Number", "SKU number",
                "Shipped Quantity", "Order Created Date"],
            colModel: [{
                name: "strNbr",
                template: intTemplate
            }, {
                name: "orderNbr",
                template: intTemplate
            }, {
                name: "skuNbr",
                template: intTemplate
            }, {
                name: "shpdQty",
                template: intTemplate
            }, {
                name: "ordCrtDt",
                template: dateTemplate
            }],
            cmTemplate: {
                width: 180
            },
            jsonReader: {
                repeatitems: false,
                id: "strNbr",
                root: function (obj) {
                    return obj;
                }
            },
            pager: "#fbPager",
            rowNum: 50,
            rowList: [50, 100, 200],
            sortName: "strNbr",
            sortOrder: "desc",
            gridview: true,
            autoencode: true,
            height: "auto",
            viewrecords: true,
            loadonce: true,
            caption: "Order Details",
            loadComplete: function () {
                rowCount();
            }
        });
    }
}
4

1 回答 1

2

立即使用loadComplete: rowcount()调用rowcount()并将其返回值传递给loadComplete而不是传递rowcountloadComplete. 您所要做的就是删除()to 而不是传递函数本身。

loadComplete: rowcount
于 2013-03-05T16:06:29.543 回答