これは、 jQgridの Actions 列にカスタム アイコンを追加するデモです。私の場合、3 行を追加すると、gridComplete が 3 回呼び出されます。したがって、1 行目に 3 つのカスタム アイコン、2 行目に 2 つ、3 行目に 1 つのカスタム アイコンを取得しています。行と列に基づいてカスタム アイコンを追加できる方法はありますか?
gridComplete: function () {
var iCol = getColumnIndexByName(grid, 'act');
$(this).find(">tbody>tr.jqgrow>td:nth-child(" + (iCol + 1) + ")")
.each(function() {
$("<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-right": "5px", float: "left", cursor: "pointer"})
.addClass("ui-pg-div ui-inline-custom")
.append('<span class="ui-icon ui-icon-document"></span>')
.prependTo($(this).children("div"));
});
}