使用角度材料以角度2将行从一张桌子转移到另一张桌子 [英] Transferring Rows from one table to another in angular 2 using angular material
问题描述
我已使用角材料在角度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.
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将行从一张桌子转移到另一张桌子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!