如果使用clickableCheckbox格式化程序,如何从jqGrid中已确认的订单行中删除删除操作图标 [英] how to remove delete action icon from confirmed order rows in jqGrid if clickableCheckbox formatter is used
问题描述
jqGrid包含操作格式化程序和布尔发布的列. 我试图使用
jqGrid contains action formatter and boolean posted columns.
I tried to hide Delete action button for posted rows in jqGrid in loadComplete
using
var iCol = getColumnIndexByName($grid, 'Posted');
$('.ui-inline-del').each(function (index) {
var row = $grid[0].rows[index];
if ($(row.cells[iCol]).find(">div>input:checked").length > 0) {
$(this).hide();
}
});
但这会在错误的行中随机隐藏删除操作按钮. 如何从发布列值为真的行中删除按钮? 奥列格
but this hides delete action button randomly in wrong rows. How to remove Delete button from rows where Posted column value is true? Oleg clickableCheckbox formatter is used in colmodel. Data is read from server in jsin format.
[{"name":"_actions",
"formatter":"actions",
,"delbutton":true,
formatoptions: {"delOptions":{"url":"Delete"}}},
{"label":null,"name":"Posted",
"edittype":"checkbox",
"editoptions":{"value":"True:False","readonly":"readonly","disabled":"disabled"},
"formatter":"clickableCheckbox",
"editable":true,"width":0,
"classes":null,"hidden":true,
}]
在删除按钮之后添加新按钮
Adding new button after delete button
$("<div>", {
title: "Custom",
mouseover: function () {
$(this).addClass('ui-state-hover');
},
mouseout: function () {
$(this).removeClass('ui-state-hover');
},
click: function (e) {
alert("'Custom' button is clicked in the rowis=" +
$(e.target).closest("tr.jqgrow").attr("id") + " !");
}
}
).css({ "margin-left": "2px", float: "left" })
.addClass("ui-pg-div ui-inline-custom")
.append('<span class="ui-icon ui-icon-lock"></span>')
.appendTo($(row.cells[iActionsCol]).children("div"));
总是显示错误的图标
推荐答案
我认为您应该将枚举从loadComplete
更改为以下内容:
I think you should change the enumeration from the loadComplete
to something like the following:
loadComplete: function () {
var i, rows = this.rows, l = rows.length, row,
iClosedCol = getColumnIndexByName($grid, 'Posted'),
iActionsCol = getColumnIndexByName($grid, '_actions');
for (i = 0; i < l; i++) {
row = rows[i];
if ($(row).hasClass('jqgrow')) {
if ($(row.cells[iClosedCol]).find(">div>input:checked").length > 0) {
$(row.cells[iActionsCol]).find(">div>div.ui-inline-del").hide();
}
}
}
}
在代码中,您可以确定在已发布"列包含选中复选框的同一行中完全隐藏了删除"操作按钮.
In the code you can be sure that you hide the "Delete" action button in exactly the same row where the 'Posted' column contains checked checkbox.
这篇关于如果使用clickableCheckbox格式化程序,如何从jqGrid中已确认的订单行中删除删除操作图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!