如何限制在标题上选择特定行在JQGRID中选择所有事件 [英] How to restrict particular Row to be selected on Header Select All event in JQGRID

查看:93
本文介绍了如何限制在标题上选择特定行在JQGRID中选择所有事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用jqGrid我已通过以下事件禁用复选框列上的行选择:

  beforeSelectRow:function(rowid,e ){
var $ myGrid = $(this),
i = $ .jgrid.getCellIndex($(e.target).closest('td')[0]),
cm = $ myGrid.jqGrid('getGridParam','colModel');

var rowData = $ grid.getRowData(rowid);
var $ isSelectable = true;
if(rowData!= null){
if(rowData.Status == -1)//行选择取决于'Status'属性行数据(-1:不可选择其他可选)
$ isSelectable = false;
}
返回$ isSelectable;
},

但是当我试图点击Header Checkbox时,它会选择所有行。我正在尝试使用事件 onSelectAll 但是在行选择过程之后它被调用,并且我无法在行选择更改之前找到调用的相应事件。请建议适当的解决方案。



修改:



网格的复选框可能有价值(即已选中/未选中)即使已禁用。



网格具有导航到另一页的超链接。

解决方案

实现您的要求的最简单方法是使用 rowattr 禁用包含<的行code>状态等于-1。





它使用以下 rowattr

  rowattr:function(rd){
if(rd.closed) {
return {
class:$(this).jqGrid(getGuiStyles,states.disabled)
};
}
}

代码使用已关闭列而不是 Status 列,并且在您的情况下,演示的输入值是布尔值而不是数字或字符串。您可以轻松修改上述代码以达到您的目的。



如果使用旧的jqGrid 4.5.2,您可以将上述代码修改为

  rowattr:function(rd){
if(rd.closed){
return {
class:ui -state-disabled ui-jqgrid-disablePointerEvents
};
}
}

并定义CSS类 ui -jqgrid-disablePointerEvents 如下所示:

  .ui-jqgrid -disablePointerEvents {
pointer-events:none;
}

演示使用jqGrid 4.5.2,它也可以。


Using jqGrid I have disabled the row selection on checkbox column click by following event:

beforeSelectRow: function (rowid, e) {
    var $myGrid = $(this),
        i = $.jgrid.getCellIndex($(e.target).closest('td')[0]),
        cm = $myGrid.jqGrid('getGridParam', 'colModel');

    var rowData = $grid.getRowData(rowid);
    var $isSelectable = true;
    if (rowData != null) {
        if (rowData.Status == -1) // Row selection depends on 'Status' property row data ( -1 : not selectable else selectable)
            $isSelectable = false;
        }
        return $isSelectable;
    },

But When i tried to click on Header Checkbox it selects all the rows. I am trying to use event onSelectAll but it is getting called after the row selection process, and I am unable to find the appropriate event that call before the Row Selection change. Please suggest appropriate solution.

Edit :

The grid's Checkbox could have value (i.e. Checked / Unchecked) even if it is disabled.

The grid have hyperlinks that navigate to another page.

解决方案

The simplest way to implement your requirements is the usage of rowattr to disable the rows having Status equal to -1.

The demo uses the free jqGrid 4.10.0 and the results on selection of all rows looks like on the picture below:

It uses the following rowattr:

rowattr: function (rd) {
    if (rd.closed) {
        return {
            "class": $(this).jqGrid("getGuiStyles", "states.disabled")
        };
    }
}

The code use closed column instead of Status column and the input values of the demo are boolean instead of numeric or strings in your case. You can easy modify the above code to your purpose.

In case of using old jqGrid 4.5.2 you can modify the above code to

rowattr: function (rd) {
    if (rd.closed) {
        return {
            "class": "ui-state-disabled ui-jqgrid-disablePointerEvents"
        };
    }
}

and define CSS class ui-jqgrid-disablePointerEvents as the following:

.ui-jqgrid-disablePointerEvents {
    pointer-events: none;
}

The demo uses jqGrid 4.5.2 and it works too.

这篇关于如何限制在标题上选择特定行在JQGRID中选择所有事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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