0

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[];



  • if you could replicate the issue that you are facing in a stackblitz instance and share the link with us, we could help you a lot faster – CCBet May 20 '22 at 10:08
  • @CCBet Hi, I actually shared my stackblitz in here as a link. – lklklklkle May 20 '22 at 10:38
  • Oh, sorry, I didn't notice it – CCBet May 20 '22 at 10:51
  • I don't know if for anybody else the solution on stackblitz is building successfully, but in my case it's throwing an error related to the file-saver dependency – CCBet May 20 '22 at 11:38
  • @CCBet You should add -primeng/api -file-saver to dependencies to the left bottom of the page. Then you should check Enable Ivy option from settings. This should download the project. – lklklklkle May 20 '22 at 11:40
  • Please trim your code to make it easier to find your problem. Follow these guidelines to create a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example). – Sumit Sharma May 23 '22 at 07:08

0 Answers0