react-table-sticky icon indicating copy to clipboard operation
react-table-sticky copied to clipboard

Support for React-window

Open engPabloMartinez opened this issue 4 years ago • 14 comments

This library is awesome, was searching for react-table 7 with sticky columns and found this one! 👏 👏 . I need to ask if there is support for react-window with sticky columns or maybe an example? I'm trying to combine react-table + this library + react-window but apparently the react-window styles mess with the styles from this library as far as I can see.

Any recommendation? advice? Maybe it's in the roadmap?

Thanks.

engPabloMartinez avatar Mar 27 '20 02:03 engPabloMartinez

Hi @engPabloMartinez Thanks for your feedback ! :) I will take time to check how the sticky hook could work with react-window. Does react-window works well alone with react-table v7 ?

GuillaumeJasmin avatar Mar 29 '20 12:03 GuillaumeJasmin

Thanks for your answer, Yes it does. https://react-table.js.org/examples/ui#virtualized-rows-react-window

I didn't have time this past weekend to do more test and research. Will try to make time this week as well.

engPabloMartinez avatar Mar 29 '20 18:03 engPabloMartinez

@GuillaumeJasmin This library is awesome! Support for React-Window would be fantastic!

iquitwow avatar Apr 09 '20 13:04 iquitwow

react-window and react-table-sticky seems incompatible because react-window add 2 new levels of <div> that break the native scroll on the root element <div className="table">. That's why the table is broken, because sticky css property can't be apply. I haven't any clean way to fix it now.

I started an IE 11 support few weeks ago (not ready yet) because sticky css property doesn't work on IE 11, and I think this fallback is the only way to make it work with react-window, but it's a fallback and the user experience is bad because the scroll is not smooth.

GuillaumeJasmin avatar Apr 10 '20 09:04 GuillaumeJasmin

Do you have any more information regarding what workaround I could try to use when using virtualized tables? Such as what styles to apply and whatnot? I don't really care about jankiness of the scroll currently.

egertaia avatar Jun 04 '20 10:06 egertaia

I also encountered the same problem, can you provide a temporary solution? Thanks.

linxu avatar Jul 31 '20 14:07 linxu

@GuillaumeJasmin

linxu avatar Jul 31 '20 14:07 linxu

@linxu here is a temporary solution: https://codesandbox.io/s/dazzling-field-48x39?file=/src/App.tsx

If you're using the FixedSizedList from react-window you can use the innerElementType prop to render the header, body and footer. I have it working with the header but not the footer. The problem with react window as you all have mentioned is that it adds 2 wrapping div elements. So, you can use the innerElementType to overcome that and render your own custom ui

jerrywithaz avatar Sep 04 '20 03:09 jerrywithaz

@jerrywithaz I tried the temporary solution and it works perfectly. But, the first two rows of the table body are hidden behind the header. It's the same in the sandbox link as well. Is there a way to fix this?

elaine0304 avatar Sep 18 '20 13:09 elaine0304

@elaine0304 ah yes, so when you're rendering your row, I think there's a row method called row.getBodyRowProps() that is responsible for setting the table row styles i.e. the row position. You need to extract the css top position for each row and add the height of your table header. So let's say the height of your table header is 50px, then you'll want to add 50px to every table row. So, the first table row won't start at 0px it will start at 50px instead to account for the header height.

jerrywithaz avatar Sep 18 '20 15:09 jerrywithaz

@linxu here is a temporary solution: https://codesandbox.io/s/dazzling-field-48x39?file=/src/App.tsx

If you're using the FixedSizedList from react-window you can use the innerElementType prop to render the header, body and footer. I have it working with the header but not the footer. The problem with react window as you all have mentioned is that it adds 2 wrapping div elements. So, you can use the innerElementType to overcome that and render your own custom ui

Awesome solution! If you mainly just want a header or footer for your table, this seems like a more straightforward approach that react-window's sticky row solution.

Only addition I would suggest is using useCallback for better performance.

E.g.

<FixedSizeList
    ...
    innerElementType={TableWrapper}
>

Where TableWrapper is:

const TableWrapper = React.useCallback({ children, style, ...rest }: any) => { yourComponent }

CuriousMark avatar Nov 19 '20 20:11 CuriousMark

@jerrywithaz @CuriousMark Cool, thank you for your response.

linxu avatar Nov 20 '20 01:11 linxu

@linxu here is a temporary solution: https://codesandbox.io/s/dazzling-field-48x39?file=/src/App.tsx

If you're using the FixedSizedList from react-window you can use the innerElementType prop to render the header, body and footer. I have it working with the header but not the footer. The problem with react window as you all have mentioned is that it adds 2 wrapping div elements. So, you can use the innerElementType to overcome that and render your own custom ui

Is there a way to make this work without using infinite-scroller, and instead with virtualized rows?

scmfz avatar May 25 '22 16:05 scmfz

I wanted to make my first column of my table sticky , my table scroll is vertical and horizontal , can anyone help me with this , i am using react-window

whiletrueee avatar Jul 05 '23 15:07 whiletrueee