1.在gridOptions中添加suppressScrollOnNewData属性
this.agGrid1.gridOptions = {
// paginationPageSize: 100,
rowHeight: 32,
headerHeight: 28,
suppressScrollOnNewData: true //支持滑动到新数据行(新增)
}
2.在grid行改变事件中执行滑动事件
//新增一条数据,当网格数据源发生改变时,自动滑动到最后一行
onRowDataChanged() {
const index = this.agGrid1.rowData.length - 1
this.agGrid1.gridOptions.api.ensureIndexVisible(index, 'bottom')
},