jqgrid: multiselect and disable check (conditional)

前端 未结 5 1738
心在旅途
心在旅途 2020-12-01 04:51


I love jqGrid but sometimes things seem more complicated than they should be.
What I would like to achieve is to have a checkbox on each row so that a user can choo

5条回答
  •  生来不讨喜
    2020-12-01 05:23

    For people (like me) that end up on this answer after searching on Google, there is a very easy solution to this problem since jqGrid 4.0.0.

    It's enough to add the css-class 'ui-state-disabled' to the row that you don't want to be selected. See The changelog of jqGrid 4.0.0. And you could still combine that with hiding or disabling the checkbox.

        var $jqgrid = $("#jqgridselector");         
        //loop through all rows
        $(".jqgrow", $jqgrid).each(function (index, row) {
            var $row = $(row);
            if ($row === condition) {
                //Find the checkbox of the row and set it disabled
                $row.find("input:checkbox").attr("disabled", "disabled");
                //add class ui-state-disabled, because thats how jqGrid knows not to take them into account for selection
                $row.addClass("ui-state-disabled");
                //I overwrite the opactity of the ui-state-disabled class to make the row look 'normal'
                $row.css("opacity", 1);
                }
            });
    

提交回复
热议问题