如何在角度材料表(mat-table)中实现编辑、更新和丢弃功能 [英] How to implement edit, update and discard functions in angular material table(mat-table)

查看:36
本文介绍了如何在角度材料表(mat-table)中实现编辑、更新和丢弃功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在角度材料表中实现编辑、更新和丢弃功能.我知道如何编辑和更新表格行,但不知道如何丢弃表格行.

I want to implement edit, update and discard functions in angular material table. I know how to edit and update table row wise but do not know how to discard the table rows.

请点击链接stackblitz 链接到表 看看我做了什么.如果您知道如何实现丢弃功能,请帮助我,任何帮助将不胜感激,我不知道如何保留数据单元格的初始值.即使我试图保留原始数据的副本,以便当他们点击丢弃按钮时,我可以将复制的数据移动到表的特定行.但是由于 2 路数据绑定它直接更新到原始数据(我的意思是公司详细信息数组,它是后端的响应),我不知道它如何反映和影响原始数据.这是我在这里面临的一件奇怪的事情,请帮助我,我需要提前得到这个答案.

please click on link stackblitz link to table to see what i have done. if you know how to implement discard functions please help me, and any help would be appreciated, i do not how to keep the initial values of data cells. even i tried to keep a copy of the original data so that when they hit on discard button i can move copied data to particular row of the table. but because of 2 way data binding its directly updating to original data(i mean to company details array which is response from backend), i do not know how its reflecting and effecting original data. its a kinda weird thing i am facing here, please help me badly i need this answer thx in advance.

推荐答案

如果您想正确实现丢弃功能,我们有一种方法,我们可以遵循反应式表单并创建表单数组,而不是遵循 2 路数据绑定.下面是我的解决方案.带有丢弃函数的表

if you wanna implement discard functionality properly we have a way, instead of following 2 way data binding we could follow reactive forms and could create form arrays. below is my solution.table with discard functions

这篇关于如何在角度材料表(mat-table)中实现编辑、更新和丢弃功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆