我在app中使用jqgrid和自定义动作格式化程序。我在loadComplete
时创建了操作。
我希望根据Col1的值禁用/启用此操作,例如,如果col1的值为true,则将操作的可见设置为true ....
怎么做?
grid.jqGrid({
url: 'jqGridHandler.ashx',
datatype: 'json',
colNames: ['Action','Col1','col2'],
colModel: [
{
name: 'act',
width: ($.browser.webkit ? 25 : 25),
align: 'center',
sortable: false,
formatter: 'actions',
formatoptions: {
keys: true,
delbutton: false,
editbutton: false
}
},
{ name: 'Col1', width: 100, sortable: true, hidden: true },
{ name: 'col2', width: 100, sortable: true, hidden: true }
],
rowNum: 20,
rowList: [5, 10, 20],
recordpos: "left",
toppager: true,
viewrecords: true,
sortorder: "desc",
scrollOffset: 1,
jsonReader:
{
repeatitems: false,
},
gridview: true,
loadComplete: function () {
var iCol = getColumnIndexByName(grid, 'act');
$(this).find(">tbody>tr.jqgrow>td:nth-child(" + (iCol + 1) + ")")
.each(function () {
$("<div>", {
title: "MyAction",
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-right": "5px", "float": "left", "cursor": "pointer" })
.addClass("ui-pg-div ui-inline-custom")
.append('<span class="ui-icon icon-archive"></span>')
.prependTo($(this).children("div"));
});
},
答案 0 :(得分:0)
我会尝试过滤集合,只做正确的单元格
var iCol = getColumnIndexByName(grid, 'act');
var iCol1 = getColumnIndexByName(grid, 'Col1');
$(this).find(">tbody>tr.jqgrow>td:nth-child(" + (iCol + 1) + ")")
// .each(function () {
.filter(function (index) {
true==$(this).find(">tbody>tr.jqgrow>td:nth-child(" + (iCol1 + 1) + ")").val();
}) {