如果在jqgrid中使用了clickableCheckBox格式化程序,如何查找布尔列值

How to find boolean column value if clickableCheckBox formatter is used in jqgrid

本文关键字:何查找 查找 布尔列 程序 jqgrid 格式化 clickableCheckBox 如果      更新时间:2023-09-26

我尝试了最近在trirand.com论坛上发布的Oleg可点击复选框格式化程序。使用以下来自其他答案的代码。它在loadComplete中查找布尔Kinnitatud列值。

下面的代码停止使用可点击的复选框格式化程序。

$(row.cells[iCol]).children("input:checked").length > 0;条件始终为假即使布尔列的值为true。

如何使其发挥作用?它与标准的复选框格式化程序配合使用。

{ "name":"Kinnitatud","edittype":"checkbox",
"formatter":"clickableCheckbox",
"editable":true,"width":0,"classes":null,"hidden":true,
}
var LoadCompleteHandler = function () {
    var iCol = getColumnIndexByName($grid, 'Kinnitatud'),
      cRows = $grid[0].rows.length,
      iRow,
      row,
      className,
      changeBackGround;
 for (iRow = 0; iRow < cRows; iRow = iRow + 1) {
   row = $grid[0].rows[iRow];
   className = row.className;
   if ($.inArray('jqgrow', className.split(' ')) > 0) {
     // changeBackGround  is always false if formatter = "clickableCheckbox" is used:
     changeBackGround = $(row.cells[iCol]).children("input:checked").length > 0;
  }
}

可以用非常简单的方式修复代码。在新的"可点击复选框"格式化程序中,<input>不是<td>的直接子级。单元格包含

<div style="position: relative;">
    <input disabled="disabled" value="true" checked="checked" type="checkbox" offval="no" />
    <div style="... position: absolute; zoom: 1; opacity: 0;" title="closed"></div>
</div>

因此,您应该将$(row.cells[iCol]).children("input:checked")替换为$(row.cells[iCol]).find(">div>input:checked")