2

我确实在 Webix Datatable 中定义了按钮模板,如下所示:

    grid = new webix.ui({
                container: "permissions",
                view: "datatable",
                columns: [
                    { id: "Id", adjust: "data", header: "&nbsp;", template: "<button value='#Id#' class='btn btn-warning btn-xs edit'><i class='glyphicon glyphicon-pencil'></i></button> <button value=#Id# class='btn btn-danger btn-xs'><i class='glyphicon glyphicon-trash'></i></button>" }
                    ...Other columns here
 }
                ],
                pager: {
                    container: "paging_here",
                    size: 10,
                    group: 5
                },
                autoheight: true,
                minHeight: 50,
                autowidth: true,
                on: {
                    onBeforeLoad: function () {
                        this.showOverlay("Загрузка данных...");
                    },
                    onAfterLoad: function () {
                        this.hideOverlay();
                    }
                },
                url: "" + _args[0] + ""
            });

不幸的是,我不知道如何获取按钮模板中定义的属性值。我尝试了类似的方法,但它不起作用:

grid.on_click.edit = function (e, id, trg, value) {
                //Core.init(["../Permissions/Edit/?id=" + e.Id]);
                //Core.loadModal();
                alert($(this).attr("value"));
                return false;
            };
4

1 回答 1

0

我得到了答案。那种方法。

grid.on_click.edit = function (e, id, trg, value) {
    alert(grid.getItem(id).Id); //Where Id is value binded in column
    return false;
};
于 2016-02-20T07:10:03.663 回答