angularng2-smart-table

disable cell when user click on 'add new' in ng2-smart-table


My settings are as given below. when I click on the 'add new' link the ID cell is editable. We want to make that field uneditable.

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

Solution

  • Found the solution for this issue. we need to add an attribute addable: false to the respected column. This attribute is not mentioned in ng2-smart-table doc.

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

    I found this solution in their example basic-example-load. https://github.com/akveo/ng2-smart-table/blob/master/src/app/pages/examples/server/basic-example-load.component.ts