1

これは、 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"));
                });
            }
4

2 に答える 2

3

answer のために作成された修正されたデモを見てください。jqGrid 4.4.4 を使用していますが、同じコード (デモを参照) が jqGrid 4.5.2 でも機能します。

于 2013-09-18T19:05:28.530 に答える