angular - 鼠标向下垫表复制值
问题描述
我创建了一个带有输入的表,以介绍用户所需的列数。在这张表中,用户介绍了数据,并且为了不单独填充数百万个单元格,我想制作一个类似单元格复制粘贴的 Excel,因此,当下拉鼠标时,复制选择的第一个值,也是水平的。我想我必须制作一个 formArray 才能为表格中的每个单元格提供单独的表单控件。
我做了一个stackblitz,我试图创建一个 formArray 但只要我在表单表中引入它,它就不起作用。单元格折叠,当检查单元格内的内容时,html 文件中没有任何内容。我正在关注本教程,但无法使其正常工作。
<form name="formTable" [formGroup]="formTable">
<table mat-table #table [dataSource]="dataSource" matTableExporter #exporter="matTableExporter" class="mat-elevation-z8" >
<ng-container matColumnDef="parameter">
<mat-header-cell *matHeaderCellDef></mat-header-cell>
<mat-cell *matCellDef="let element;" >{{element.parameter}}</mat-cell>
</ng-container>
<ng-container [matColumnDef]="column" *ngFor="let column of columnsToDisplay">
<th mat-header-cell *matHeaderCellDef> {{column}} </th>
<td mat-cell *matCellDef="let element; let i = index" (mousedown)="onMouseDown(i, column)" (mouseup)="onMouseUp(i, column)" >
<div class="cells" *ngFor="let dataValue of dataValues().controls; let i=index">
<div [formGroupName]="i">
<mat-form-field floatLabel="never" appearance="none" >
<input matInput [value]="0" formControlName="dataValue" name="someValue" >
</mat-form-field>
</div>
</div>
</td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
</table>
</form>
我使用的这段代码来自 Rakia,如果你想看看,这里是链接。可编辑表
解决方案
推荐阅读
- go - 如何更新嵌套的 protobuf 字段
- .net - .net 远程属性,页面加载后如何调用?
- blockchain - 有没有办法在以太坊上使用没有智能合约的多重签名?
- google-apps-script - 使用 App 脚本连续获取新的输入值
- solr - 如何将 Apache Solr 中的图像数据显示和检索到网页中的图像中?
- python - 如何将模算术方程转换为python代码?
- python - 按下全局热键时在 Macos 上运行功能
- flutter - 如何将 Android 模拟器添加到 VS 代码?
- python - 尝试制作日志功能
- git - Eclipse Egit 无法登录 Bitbucket