jqgrid - Disable Header Check box (multiselect = true) if all rows are disable

后端 未结 2 1969
感动是毒
感动是毒 2021-01-26 02:17

Using jqgrid with multiSelect=\"true\" option. I am disabling rows and prevent its selection based on some flag status as mentioned below

Disable row(s) bas

相关标签:
2条回答
  • 2021-01-26 02:32

    I would suggest you to save the information whether all row are disabled or not inside of your custom option of jqGrid. The corresponding code could be like on the demo http://jsfiddle.net/OlegKi/aagxejj5/44/ which uses

    rowattr: function (item, rd, rowid) {
        var p = $(this).jqGrid("getGridParam");
        if (rd.closed === "true" || rd.closed === true) {
            return {"class": "ui-state-disabled ui-jqgrid-disablePointerEvents"};
        } else {
            p.isSomeEnabled = true;
        }
    },
    beforeRequest: function () {
        var p = $(this).jqGrid("getGridParam");
        p.isSomeEnabled = false; // reset for the filling
    },
    loadComplete: function () {
        var p = $(this).jqGrid("getGridParam"), $selAll = $("#cb_" + this.id);
    
        if (p.isSomeEnabled) {
            $selAll.removeClass("ui-state-disabled ui-jqgrid-disablePointerEvents");
            $selAll.click(); // select all
            // one need to trigger the click twice only because of bugs
            // in case of usage old jQuery version
            $selAll.click(); // select all
            $selAll.prop("checked", true);
        } else {
            $selAll.addClass("ui-state-disabled ui-jqgrid-disablePointerEvents");
            $selAll.prop("checked", false);
        }
    }
    

    I placed one enabled on the second page, so one can switch the pages and see that the above code correctly work.

    0 讨论(0)
  • 2021-01-26 02:41

    The checkbox in the header has the id which is combined from the "cb_" prefix and the grid id. So you can hide the element with

    var myGrid = $("#list"); $("#cb_"+myGrid[0].id).hide();

    0 讨论(0)
提交回复
热议问题