The problem of table component about scroll in antd

official example: https://ant.design/components...

how to control how to position the current scroll bar to the top of the table when you turn the page? This ensures that the list data is read from top to bottom each time you turn the page.

the current official scroll bar is still in place after the current page reading list has slipped down.

Apr.29,2022

you can write one yourself.

get the dom of table

<Table ref={(ref)=>this.table=ref} />
const table = ReactDom.findDOMNode(this.table),
      tableBody = table.querySelector('.ant-table-body');

then when you turn the page, just put the scroll bar to the top

tableBody.scrollTop = 0;
After

3.24.0, the configuration item scrollToFirstRowOnChange has been added to the scroll attribute. You can try it.


you can try to get the table element and set it scrollTop to 0

every time you click to turn the page.
Menu