我在 Angular 7 应用程序上使用 PrimeNG TurboTable 组件,并且有一个按钮可以向其中添加新行。问题是,当添加新行时,用户必须向下滚动到表格底部才能开始编辑它。我怎么能滚动到它?
这就是我在模板中定义表格的方式:
<p-table [value]="gridOptions" [scrollable]="true" scrollHeight="13em"
selectionMode="single" [(selection)]="selectedOption"
(onEditComplete)="onDataChanged($event)"
(onRowReorder)="onDataChanged($event)">
[ ... ]
</p-table>
这是“添加选项”处理程序:
onAddOption() {
// This adds a new option to the TurboTable
this.gridOptions.push({ name: "", arg: "", comment: "", scope: this.scope });
// I expected that selecting an option would scroll to it, but it doesn't work
this.selectedOption = this.gridOptions[this.gridOptions.length-1];
}
有任何想法吗?谢谢!