【问题标题】:disable cell when user click on 'add new' in ng2-smart-table当用户在 ng2-smart-table 中单击“添加新”时禁用单元格
【发布时间】:2020-10-24 15:13:32
【问题描述】:

我的设置如下。 当我单击“添加新”链接时,ID 单元格是可编辑的。我们想让该字段不可编辑。

mySettings = {
columns: {
        id: {
            title: 'ID',
            editable: false,
        },
        name: {
            title: 'Name',
        },
        lastname: {
            title: 'Last Name',
        },
    }
};

【问题讨论】:

    标签: angular ng2-smart-table


    【解决方案1】:

    找到了解决此问题的方法。 我们需要将属性addable: false 添加到受尊重的列。 ng2-smart-table 文档中没有提到这个属性。

    tableSettings = {
        mode: 'inline',
          columns: {
            name: {
              title: 'Name',
              editable:false,
              addable: false,
            },
            lastname: {
              title: 'Last Name',
            },
          } // columns
      } 
    

    我在他们的示例 basic-example-load 中找到了这个解决方案。 https://github.com/akveo/ng2-smart-table/blob/master/src/app/pages/examples/server/basic-example-load.component.ts

    【讨论】:

    • 谢谢,奇怪的是他们的文档中仍然没有这个
    【解决方案2】:

    在根对象中使用actions: false

    tableSettings = {
          actions: false,
          columns: {
            lastname: {
              title: 'Last Name',
            },
          } // columns
      }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-06-08
      • 1970-01-01
      • 2020-03-10
      • 1970-01-01
      相关资源
      最近更新 更多