添加自定义操作按钮-ng2-smart-table

Let*_*ima 4 ng2-smart-table

我正在尝试向自定义操作添加按钮,但是该操作未添加新列,从而使按钮与其他按钮重叠。

码:

settings = {
    actions: {
      custom: [
        {
          name: 'Button',
          title: 'Button ',
        }
      ],
    },
    columns: {
      name: {
        title: 'Full name'
      },
      email: {
        title: 'Email'
      },
      lastLogin: {
        title: 'Last Login'
      }
    }
  };
Run Code Online (Sandbox Code Playgroud)

我需要在图像上添加一个链接,因为我在这里的声誉不高,并且图像工具对我来说是被阻止的。

反应图片:

我究竟做错了什么?

小智 11

你可以试试看 将设置更改为:

settings = {
hideSubHeader: true,
actions: {
  custom: [
    {
      name: 'yourAction',
      title: '<i class="ion-document" title="YourAction"></i>'
    },
    {
      name: 'editAction',
      title: '<i class="ion-edit" title="Edit"></i>'
    },
    {
      name: 'deleteAction',
      title: '<i class="far fa-trash-alt" title="delete"></i>'
    }
  ],
  add: false,
  edit: false,
  delete: false
}
...
};
Run Code Online (Sandbox Code Playgroud)

然后将此添加到您的component.scss

    :host /deep/ ng2-st-tbody-edit-delete {display: flex !important;
  height: 0 !important;
}

:host /deep/ ng2-st-tbody-custom a.ng2-smart-action.ng2-smart-action-custom-custom {
  display: inline-block;
  width: 50px;
  text-align: center;
  font-size: 1.1em;
}

:host /deep/ ng2-st-tbody-custom a.ng2-smart-action.ng2-smart-action-custom-custom:hover {
  color: #5dcfe3;
}
Run Code Online (Sandbox Code Playgroud)

  • 谢谢,它有很大帮助,其他想法是我们如何在这些点击上调用方法? (2认同)