Angular 5 + ng2-smart-table : Hide/disable actions column conditionally

标签 angular ng2-smart-table

我有一个由 ng2-smart-table 构建的表,表中的数据有两种状态为 DraftReady .当data.status = 'Draft' ,可以为 CRUD 目的显示操作列,但随后状态更改为 data.status = 'Ready' ,我想禁用操作列。如何有条件地做到这一点?

桌面设置:

  tableSettings = {
    add: {
      addButtonContent: '<i class="fas fa-plus fa-fw"></i>',
      createButtonContent: '<i class="fas fa-plus fa-fw"></i>',
      cancelButtonContent: '<i class="fas fa-times fa-fw"></i>',
      confirmCreate: true
    },
    edit: {
      editButtonContent: '<i class="fas fa-pencil-alt fa-fw"></i>',
      saveButtonContent: '<i class="fas fa-check fa-fw"></i>',
      cancelButtonContent: '<i class="fas fa-times fa-fw"></i>',
      confirmSave: true
    },
    delete: {
      deleteButtonContent: '<i class="far fa-trash-alt fa-fw"></i>',
      confirmDelete: true
    },

    columns: {
      title: {
        title: 'Title',
        type: 'text',
        filter: false,
      },
      description: {
        title: 'description',
        type: 'text',
        filter: false,
      }
    }
  };

ngOnInit() {
  this.apiService.getData.subscribe((res: any) => {
    this.data = res;
    console.log(this.data.status);
  });
}

最佳答案

也许有点晚了,但是在你的设置中设置“actions: false”,你可以用一个变量做动态

关于Angular 5 + ng2-smart-table : Hide/disable actions column conditionally,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50817642/

相关文章:

angular - 使用 angularfire2 时要在 ngrx/store 中存储什么?

angular - DOM nativeElement 是否有 typescript 定义?

NG2-智能表单细胞造型

angular - ng2-smart-table 派生列

css - 如何在 ng2-smart-table 上显示自定义图标?

javascript - 如何使一个 Angular 指令只能由一个组件使用?

angular - Angular 2 http官方教程中的私有(private)变量命名约定

Angular 2 数据绑定(bind)和 setTimeout

angular - 如何更新 ng2-smart-table 中的分页操作

javascript - 是否可以使用自定义组件或任何其他方式自定义 ng2-smart-table 的列标题?