javascript - 虽然这是重复的问题,但我如何在第一行显示新行我正在使用 angular9
问题描述
我可以添加一个新行,但它在最后一页上。我想显示在第一行。谁能帮我解决这个问题?HTML 组件
<button mat-button color="primary" (click)="addRow()">
<mat-icon>add</mat-icon>
<span>Add</span></button>
ts代码
addRow(){
this.agGrid.api.applyTransaction({
add: [{make: '', model: '', price: ''}]
});
解决方案
您可以使用updateRowData
网格 Api 上的方法,它允许您指定要插入的索引。addRow
将您的方法更改为:
addRow() {
let newRows = [{ make: "", model: "", price: '' }];
this.gridApi.updateRowData({ add: newRows, addIndex: 0 });
}
看看这个StackBlitz。
推荐阅读
- c - 矩阵中的最后一个数字是错误的
- go - 如何将元数据从 grpc-gateway 发送到 grpc 服务器?
- imagemagick - 托管主机上的 imagemagick 脚本
- python - 未绑定方法调用中的参数 self 没有值
- blockchain - 几个 Cordapp 可以访问同一个账本?
- apache-spark - 无法在 Azure Databricks 提供的 Spark 群集中导入已安装的 Python 模块
- java - Spring Boot 安全配置无法与角色/权限正常工作
- scala - 带有 sbt 程序集的 fatjar 上的“找不到类 org.apache.hadoop.fs.s3a.S3AFileSystem”
- xaml - *.xaml.g.cs 文件显示过时警告 (CS0618)。如何在部分类中使用过时的属性?
- php - 登录后,重定向在 CakePHP 中不起作用