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

2

5

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',
        },
    }
};
Strangulate answered 23/1, 2018 at 14:21 Comment(0)
S
7

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

Strangulate answered 5/2, 2018 at 11:47 Comment(1)
Thanks, it's so strange that they still don't have this in their documentationBrainwashing
D
0

Use actions: false in root object

tableSettings = {
      actions: false,
      columns: {
        lastname: {
          title: 'Last Name',
        },
      } // columns
  }
Defecate answered 24/10, 2020 at 7:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.