简体   繁体   中英

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

I tried Oleg clickable checkbox formatter recently posted in trirand.com forum. Code below from other answer is used. It finds boolean Kinnitatud column value in loadComplete.

Code below stops working with clickable checkbox formatter .

$(row.cells[iCol]).children("input:checked").length > 0; condition is always false even if boolean column has value true.

How to make it work ? It works with standard checkbox formatter.

{ "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;
  }
}

The code can be fixed in very easy way. In the new 'clickableCheckbox' formatter the <input> in not direct child of the <td> . The cell contain is

<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>

So you should replace $(row.cells[iCol]).children("input:checked") to $(row.cells[iCol]).find(">div>input:checked") .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM