【问题标题】:jqGrid - How to unselect the header row checkboxjqGrid - 如何取消选择标题行复选框
【发布时间】:2011-06-08 16:10:37
【问题描述】:
Here is the scenario:

1。通过选中标题行复选框来选择所有行。 2. 取消选择一行。 3. 标题行复选框仍然被选中,这是无效的,因为不是所有的行都被选中。

如何取消选中 hedaer 行复选框? 谢谢

【问题讨论】:

    标签: header checkbox jqgrid row


    【解决方案1】:

    您可以执行以下操作:

    var grid = $("#ID_OF_YOUR_GRID");
    
    grid.jqGrid({
            //other options
            multiselect: true,
            onSelectRow: function (rowid, status) {     
               var chkSelectAll = $("#ID_OF_THE_HEADER_CHECKBOX_USUALLY_CB_DATA");
    
               if (chkSelectAll.length && chkSelectAll.is(':checked') && !status) {          
                  chkSelectAll.removeAttr('checked');
               }
             }
         });
    

    顺便说一句。您只需要在旧版本的 JQGrid 上使用它。我已经签入了 4.3.1 版本,这是开箱即用的。

    【讨论】:

      【解决方案2】:

      您可以使用resetSelection 方法。查看为thisthis 问题准备的the example。 “清除选择”按钮使用resetSelection 方法。

      【讨论】:

      • resetSelection 将取消选择所有行。我们需要做的是取消选中标题复选框,但保留当前选中的行。
      • @Darren:如果您应该使用getDataIDs 获取当前选定行的id,请调用resetSelection,然后调用setSelection 以获取所有先前选择的id。请参阅示例ok-soft-gmbh.com/jqGrid/DataToMultiSelect2.htm 中单击"Select All" 按钮时执行的代码。稍作修改后,您将拥有所需的内容。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-12-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-10-09
      相关资源
      最近更新 更多