jqgrid-如果所有行都被禁用,则禁用标题复选框(multiselect = true) [英] jqgrid - Disable Header Check box (multiselect = true) if all rows are disable

查看:83
本文介绍了jqgrid-如果所有行都被禁用,则禁用标题复选框(multiselect = true)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将jqgrid与multiSelect="true"选项一起使用.我正在禁用行,并根据如下所述的某些标志状态阻止对其进行选择

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

基于IS_FLAGGEd = 1

//disable row which are flagged
        rowattr: function (item) {
                if (parseInt(item.IS_FLAGGED) == 1) {
                    return {"class": "ui-state-disabled ui-jqgrid-disablePointerEvents"};
                }
        },

        //prevent selection of disabled rows
        beforeSelectRow: function (rowid, e) {
            if ($(e.target).closest("tr.jqgrow").hasClass("ui-state-disabled")) {
                return false;   // not allow select the row
            }
            return true;    // allow select the row
        }

要禁用标头复选框,已在以下代码中实现,但是即使禁用了一行,它也会禁用标头复选框.

To disable header checkbox, implemented below code, but it disables the header check box even if one row is disabled.

//disable header checkbox only if all rows are disabled        
        loadComplete: function() {
            var grid = $("#grid");
            var ids = grid.jqGrid('getDataIDs');
            for(var i=0;i < ids.length;i++){
                var rowId = ids[i];
                var rowData = jQuery('#grid').jqGrid ('getRowData', rowId);
                console.log(rowData.SUBMIT_TO_ACC);
                 if(rowData.FLAG_STATUS == 1){
                    $('tr.ui-jqgrid-labels').addClass('ui-state-disabled ui-jqgrid-disablePointerEvents');
                }
            }
        }

仅在禁用ALL行即hasClass(ui-state-disabled)时,如何才能禁用标题复选框(multiselect = true)?

How can I disable Header Check box (multiselect = true), only when ALL rows are disabled i.e hasClass(ui-state-disabled) ?

jQgrid版本= 4.6
jQuery版本= 1.7.2

jQgrid version = 4.6
jQuery version = 1.7.2

推荐答案

标题中的复选框具有ID,该ID由"cb_"前缀和网格ID组合而成.因此,您可以使用

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();

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

这篇关于jqgrid-如果所有行都被禁用,则禁用标题复选框(multiselect = true)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆