mui-datatables
mui-datatables copied to clipboard
Possible to scroll to the selected row?
Currently, I am facing 2 problems, hope could get suggestion.
-
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.
-
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 |
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.
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.
Has anyone figured this out?