我试图使p表滚动条滚动到一个特定的位置。它似乎什么也没做。这是我的密码:
ngAfterViewInit(): void {
this.table.scrollTo({'top': 200})
}"this.table“是
@ViewChild('dt', {static: false}) public table: Table;在模板文件中,它是这样定义的:
<p-table #dt
[value]="items"
class="ui-rtl"
[styleClass]="styleClass"
[scrollable]="true"
[columns]="columns"
scrollHeight="790px"
dir="rtl">忽略硬编码的数字,我只是想知道如何使它工作到目前为止。
有人知道怎么用吗?文件上说:
options.top:指定沿Y轴的像素数
我试图将{'options.top':200}和{top:200}作为参数传递,但什么也没有发生。
任何帮助都将不胜感激!
谢谢
发布于 2021-12-13 11:26:12
试试这个,这对我有用
const body = this._materialTable.containerViewChild.nativeElement.getElementsByClassName('p-datatable-scrollable-wrapper')[0];
body?.scrollTo({
top: 0,
left: 10,
behavior: 'smooth'
});https://stackoverflow.com/questions/66654629
复制相似问题