使用角度材料以角度2将行从一张桌子转移到另一张桌子

编程入门 行业动态 更新时间:2024-10-23 03:19:20
本文介绍了使用角度材料以角度2将行从一张桌子转移到另一张桌子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我已使用角材料在角度2中实现了简单表...我采用了两个mat-table,其中单击移至表2"时将第一张表中的选定行转移到第二个表,单击移至表"中则反之亦然1

但是,当我选择并单击Move To Table 2时,我的第一张表中的行将被拼接和传输,但是与第二行中的行相同,我将在第二张表中再次获得先前传输的行./p>

示例示例

下面显示的是我的输出.

最初,当我转移第一行时,它会被拼接并移到第二张表中.

但是当我转移第二行时,先前移动的行会再次添加到第二张表中.

解决方案

那是因为您没有清除选择内容,

从一张桌子到另一张桌子的转移完成后,您需要做的就是清除选择

在moveToTableTwo()的末尾添加this.selection.clear();,例如:

moveToTableTwo(){ ... this.selection.clear(); }

I have implemented simple table in angular 2 using angular material...I have taken two mat-table where the selected rows from first table are transferred to second table on clicking Move To Table 2 and vice versa on clicking Move To Table 1

But as I select and Click on Move To Table 2 , the row from my first table is getting spliced and transferred but as do the same for the second row, I am getting the previously transferred row again in my second table.

Sample Example

Below shown is my output.

Initially when I transfer first row , its getting spliced and moved to second table .

But when I transfer second row ,the previously moved row is again added in the second table.

解决方案

That is because you are not clearing the selection ,

All you need to do is clear the selection once the transfer from one table to another is finished

Add this.selection.clear(); this at the end of moveToTableTwo() , like :

moveToTableTwo(){ ... this.selection.clear(); }

更多推荐

使用角度材料以角度2将行从一张桌子转移到另一张桌子

本文发布于:2023-10-28 18:17:24,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1537400.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:桌子   角度   材料   转移到

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!