0

In ng2-smart-table, I want a button 'Start' or 'End' which I am showing conditionally. How can I do this? I am having a condition If that's true, then I want to show 'Start' button and if it is false, then I want to show 'End' button. Also, I need to perform something if a user clicks these buttons.

tableSettings = {
actions: false,
columns: {
  code: {
    title: 'Code'
  },
  first_name: {
    title: 'First Name'
  },
  last_name: {
    title: 'Last Name'
  },
  email_id: {
    title: 'Email'
  },
  start_time: {
    title: 'Start Time',
    type: 'date',
    valuePrepareFunction: (date) => { 
      return this.renderDateTime(date); 
    }
  },
  end_time: {
    title: 'End Time',
    type: 'date',
    valuePrepareFunction: (date) => {
      return this.renderDateTime(date); 
    }
  },
  start: {
    title: 'Start/End',
    type: 'html',
    valuePrepareFunction: (cell, row) => {
      return `<button *ng-If="renderButton(row) === 'Start'" (click)="startTest()">Start</button>`; 
    }
  }
}

};

Naveen Kumar
  • 2,570
  • 3
  • 20
  • 22

1 Answers1

0

I gave one answer on this valuePrepareFunction. This may help you.

Sachin Shah
  • 4,503
  • 3
  • 23
  • 50