Rohan Joshi
Rohan Joshi

Reputation: 24

how to enable editable property of ng2-smart-table conditionally

I am using ng2-smart-table. I want to make field editable when it's empty otherwise not.

  location: {
    title: 'Location',
    width: '20px',
    filter: false,
    valuePrepareFunction: (value) => {
      if (value !== '') {
        editable : false
      } else {
        editable: true
      }
    }
  }

Upvotes: 0

Views: 1070

Answers (1)

Sachin Shah
Sachin Shah

Reputation: 4533

You can use CSS for this in this way.

rowClassFunction: (row) => {
   console.log("\nRow is ::: ",row.data);            
   if (row.data == '')) {
       return 'hide_edit';
   }
 }

To apply this CSS dynamically, Set CSS code in component's .css file...

:host ::ng-deep .hide_edit{
   display:none;
}

Upvotes: 1

Related Questions