如何添加按钮jqgrid中的动作按钮
问题描述:
Custom jQGrid post action答案使用appendTo()添加自定义按钮到动作结束按钮。如何添加按钮jqgrid中的动作按钮
如何为操作按钮添加按钮?
我试图用before()和prepend()替换appendTo(),但是在此所有按钮消失。
答
我试图用prependTo
而不是appendTo
和所有的作品。到恰好我用
loadComplete: 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"));
});
}
相应demo显示
我加入另外CSS
.ui-inline-custom.ui-state-hover span { margin: -1px; }
为悬停的小的改进对应这已经在实施the bug fix jqGrid 4.3.2。
更新:当前版本的free jqGrid支持简单的方法来实现自定义按钮。见the demo。