mui-datatables icon indicating copy to clipboard operation
mui-datatables copied to clipboard

Possible to scroll to the selected row?

Open Zero-Xiong opened this issue 6 years ago • 3 comments

Currently, I am facing 2 problems, hope could get suggestion.

  1. for the option, I enabled selectableRows = 'single' and filterType = 'checkbox', and the rowsSelected is from useState ( const [rowsSelected, setrowsSelected] = useState([2])). Now the problem is: Once the rowsSelected changed (for example, somewhere, I setrowsSelected([5])), it does not reflect on tables immediately.

  2. according to question NO.1, since the rowsSelected is supported, do we have the possibility to scroll to the selected row? As you see, I changed the rowsSelected by setrowsSelectected([10]), somehow (in some situation) we need to scroll to the new selected row.

Tech Version
Material-UI v4.3.3
MUI-datatables >= v2.10.0
React 16.8.6
browser Chrome

Zero-Xiong avatar Sep 13 '19 00:09 Zero-Xiong

Hello @Zero-Xiong. I'm afraid I don't have enough information yet to be able to help you with the first problem. For starters, your versions material and react are not officially supported by this library yet. Can you create a codesandbox example with material v3 that does not use hooks? Then I can take a look.

Regarding the second question, there's nothing built in to do this for you, but you can create custom functionality that could do this by using customBodyRender to create your own cells with ids, and then scroll the page to it in some callback after the updates are successful.

gabrielliwerant avatar Sep 13 '19 01:09 gabrielliwerant

Thanks @gabrielliwerant I have solved the 1st problem by using function directly instead (can not managed by state, because it delays) For 2nd, still exploring.

Zero-Xiong avatar Sep 13 '19 01:09 Zero-Xiong

Has anyone figured this out?

Falgianot avatar Feb 09 '22 15:02 Falgianot