Free jqgrid contain boolean hidden column IsPosted defined as
{"label":null,"name":"IsPosted",
"edittype":"checkbox","editoptions":{"value":"True:False","readonly":"readonly","disabled":"disabled"},
"align":"center",
"formatter":"checkboxFontAwesome4",
"editable":true,
"width":0,"classes":null,
"hidden":true,"stype":"select",
"searchoptions":{"sopt":["eq","ne"],
"value":":Free;true:Yes;false:No"}
}],
delete, edit and custom post button needs to be removed from inline actions toolbar if this column has value true. Rhis is done using method
disableRows('IsPosted', true);
It works with Clickable checkbox formatter. If checkboxFontAwesome4 formatter is used,
isPosted = $(row.cells[iCol]).find(">span>div>input:checked").length > 0;
is always false. I tried also
isPosted = $(row.cells[iCol]).children("input:checked").length > 0;
but this is false for all formatters. I tried also template = "booleanCheckboxFa",
instead of formatter line but this does not show fontawecome icon.
How to fix it so that it works with checkboxFontAwesome4 formatter or with all formatters ?
var disableRows = function (rowName, isBoolean) {
var iCol = getColumnIndexByName($grid, rowName),
cRows = $grid[0].rows.length,
iRow,
row,
className,
isPosted,
mycell,
mycelldata,
cm = $grid.jqGrid('getGridParam', 'colModel'),
iActionsCol = getColumnIndexByName($grid, '_actions'), l;
l = cm.length;
for (iRow = 0; iRow < cRows; iRow = iRow + 1) {
row = $grid[0].rows[iRow];
className = row.className;
isPosted = false;
if ($(row).hasClass('jqgrow')) {
if (!isBoolean) {
mycell = row.cells[iCol];
mycelldata = mycell.textContent || mycell.innerText;
isPosted = mycelldata.replace(/^\s+/g, "").replace(/\s+$/g, "") !== "";
}
else {
isPosted = $(row.cells[iCol]).find(">span>div>input:checked").length > 0;
}
if (isPosted) {
if ($.inArray('jqgrid-postedrow', className.split(' ')) === -1) {
row.className = className + ' jqgrid-postedrow not-editable-row';
$(row.cells[iActionsCol]).attr('editable', '0');
$(row.cells[iActionsCol]).find(">div>div.ui-inline-del").hide();
$(row.cells[iActionsCol]).find(">div>div.ui-inline-post").hide();
$(row.cells[iActionsCol]).find(">div>div.ui-inline-edit").hide();
}
}
}
}
};