Currently, I am implementing the functionality of adding new rows to a dataTable in my template. Here is the code snippet from the component:
rows: any = {}
newrow: any = {}
addNewRow(key: string) {
let rows = {...this.rows}
let newrow = {_key: Math.floor(Math.random() * 10000), title: this.newrow.title}
if (rows[key]) {
rows[key].push(newrow)
} else {
rows[key] = newrow
}
this.rows = rows
}
I found a useful tutorial on PrimeFaces' website, which has been quite helpful in guiding me through this process.
The issue I'm facing is that only the first row is being rendered in the table, even though when I check the values using {{rows | json}}
in the template, all the data seems to be present:
{
"210386": [
{
"_key": 9173,
"title": "Row one"
},
{
"_key": 6201,
"title": "Row Two"
}
]
}