我已使用角材料在角度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将行从一张桌子转移到另一张桌子
发布评论