免费 jqgrid 包含布尔隐藏列 IsPosted 定义为
{"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"}
}],
如果此列的值为 true,则需要从内联操作工具栏中删除删除、编辑和自定义发布按钮。Rhis是使用方法完成的
disableRows('IsPosted', true);
它适用于可点击复选框格式化程序。如果使用 checkboxFontAwesome4 格式化程序,
isPosted = $(row.cells[iCol]).find(">span>div>input:checked").length > 0;
总是假的。我也试过
isPosted = $(row.cells[iCol]).children("input:checked").length > 0;
但这对所有格式化程序都是错误的。我也尝试过template = "booleanCheckboxFa",
代替格式化程序行,但这没有显示 fontawecome 图标。
如何修复它以使其与 checkboxFontAwesome4 格式化程序或所有格式化程序一起使用?
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();
}
}
}
}
};