如何为backgrid行添加自定义删除选项 [英] How to add a custom delete option for backgrid rows

查看:107
本文介绍了如何为backgrid行添加自定义删除选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 backgrid 开发了可编辑网格,看起来也不错。以下是我的输出:

i have developed editable grid using backgrid and it looks good also. following is my output :

当我选中复选框并单击删除图标,然后选中的行是已删除。

when i select the check box and click on delete icon, then the selected rows are deleted.

现在我还希望每行都有删除选项,以便用户可以直接删除该行。

now i also would like to have the delete option on each row so that the user can delete the row directly.

如何在每一行上添加删除图标。??

How to put delete icon on each row.??

推荐答案

您可以制作自定义单元格。

You can make a custom cell.

var DeleteCell = Backgrid.Cell.extend({
    template: _.template(" PUT YOUR HTML BUTTON TEMPLATE HERE "),
    events: {
      "click": "deleteRow"
    },
    deleteRow: function (e) {
      e.preventDefault();
      this.model.collection.remove(this.model);
    },
    render: function () {
      this.$el.html(this.template());
      this.delegateEvents();
      return this;
    }
});

这篇关于如何为backgrid行添加自定义删除选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆