Angular 取消编辑ngx数据表中的行并返回到以前的数据
我正在运行此示例,并试图通过单击“取消x”按钮并使用以前的数据重置所选行来取消编辑行。我将数据保存到localstorage,但在取消编辑后得到空数据。有帮助吗 这是取消操作的代码:Angular 取消编辑ngx数据表中的行并返回到以前的数据,angular,angular-material,Angular,Angular Material,我正在运行此示例,并试图通过单击“取消x”按钮并使用以前的数据重置所选行来取消编辑行。我将数据保存到localstorage,但在取消编辑后得到空数据。有帮助吗 这是取消操作的代码: cancel(row, rowIndex) { this.isEditable[rowIndex] = !this.isEditable[rowIndex]; // this.rows = this.data; this.rows = [...[]]; this.rows.push
cancel(row, rowIndex) {
this.isEditable[rowIndex] = !this.isEditable[rowIndex];
// this.rows = this.data;
this.rows = [...[]];
this.rows.push(JSON.parse(localStorage.getItem("data")));
// this.rows.forEach(row => {
// let testArr = [];
// row.nota.forEach(nota => {
// testArr.push(nota.test);
// });
// row.selected = testArr;
// });
this.rows = [...this.rows];
// this.rows = [...this.rows];
console.log("Row canceled: " + rowIndex);
}
您正在使用
行。推送(…)
并向其传递数组,这不起作用
替换
this.rows = [...[]];
this.rows.push(JSON.parse(localStorage.getItem("data")));
与
那会让你走的
this.rows = JSON.parse(localStorage.getItem("data"));