How to add a new row to p-table when the table is empty?

845 views Asked by At

I have a datatable with mock data and multiple rows and an add button in the end to add a new row. The problem is when there is no data in the table, I mean no rows, the add button doesn't add the initial row?

I took this as a reference: here

My stackblitz code: here

app.component.ts

triggerAdd() {
   
  this.addMode = !this.addMode;
}
onRowAddSave(customer: any) {

  if(Object.keys(customer).length !== 0 ){
 
    this.launchMaturity.push(customer);
    this.formatProduct(this.launchMaturity);
    this.addMode = false;
    this.newAttribute = {};
  }
}
onRowCancelSave() {
  this.addMode = false;
}
}


public formatProduct(value: any) {
  this.formatData = [];
  this.exportable = true;

  value.map((a: any) => this.formatData.push(a));

 }
}

public launchMaturity: any[];



0

There are 0 answers