I have an issue with primeNG datatable, when updating the datasouce the datatable does not automatically update. I have two datatables in different components that are communicating via a service, when clicking on one row in the first datatable a method is called which updates the datasource, however the second datatable does not recognize it. Maybe someone had a similar issue or has an example of how to solve issues like that with primeNG datatable? I would appreciate any help.
in my case:push data into tableData array, then copy tableData array itself (use slice())
export class DataTableComponent{
tableData=[];
county={id:1,name:"china"}
onAdd(){
this.tableData.push( Object.assign({}, this.country));
this.tableData=this.tableData.slice();
}
}
and it works
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With