Replies: 4 comments 4 replies
-
Hi @mtshv, Thank You. |
Beta Was this translation helpful? Give feedback.
-
Hi! Brother, I tried to write an example, I don't know if it is what you need |
Beta Was this translation helpful? Give feedback.
-
Here is my working solution const {
getTableProps,
headerGroups,
rows,
prepareRow,
getTableBodyProps,
state,
} = useTable(
{
columns,
data,
defaultColumn,
},
useFlexLayout,
useResizeColumns,
);
// the reason why this callback is a function returning a function
// is because I also needed the useRowSelect to display the state of checkboxes properly
const renderRow = useCallback(
(rows: Row<T>[]) =>
({ index, style }: any) => {
const row = rows[index];
// just a normal table row stuff, like in any example, except you should pass style to the parent element of it, obviously
return (
<TableRow
prepareRow={prepareRow as any}
row={row as any}
style={style}
/>
);
},
[prepareRow]
);
return (
<div
style={{
height: "calc(100vh - 152px);", // depending on your use case, you might not need it
overflowY: "hidden",
overflowX: "auto", // important
}}
>
<table
{...getTableProps()}
style={{
height: "100%",
overflow: "hidden", // important
tableLayout: "fixed",
}}
>
<thead style={{ overflow: "hidden" /* also important, otherwise you would get head resizing, while other rows would not */ }}>
{headerGroups.map((headerGroup) => (
<tr
{...headerGroup.getHeaderGroupProps({ style: { width: "100%" /* also important */ } })}
>
{headerGroup.headers.map((column) => (
<th {...column.getHeaderProps()}>
{column.render("Header")}
{/* below is a regular resizer from examples */}
<Resizer column={column} />
</th>
))}
</tr>
))}
</thead>
<tbody
{...getTableBodyProps()}
style={{ height: "100%", overflow: "hidden" /* important for react-window autosizer */ }}
>
<ReactVirtualizedAutoSizer disableWidth>
{({ height }) => (
<InfiniteLoader
itemCount={itemCount}
isItemLoaded={isItemLoaded}
loadMoreItems={loading ? () => {} : loadMoreItems}
minimumBatchSize={20}
>
{({ onItemsRendered, ref }) => (
<FixedSizeList
height={height}
itemCount={rows.length}
onItemsRendered={onItemsRendered}
ref={ref}
// below might be important, I have no idea, maybe "auto" is fine too
width="100%"
itemSize={52}
>
{renderRow(rows)}
</FixedSizeList>
)}
</InfiniteLoader>
)}
</ReactVirtualizedAutoSizer>
</tbody>
</table>
</div>
); |
Beta Was this translation helpful? Give feedback.
-
i fixed it by using this code Table ==> |
Beta Was this translation helpful? Give feedback.
-
Hey guys!
I am struggling to combine the functionality of the Full Width Resizable Table example with Virtualized Rows (React-Window) example
The problem, that I have is that header columns and body columns are not aligned.
Case A:
Setting width of the FixedSizeList to totalColumnsWidth results in not full-width table body
Case B:
Removing width property from the FixedSizeList OR Setting it to "100%" results in the full-width table body BUT headers columns and body columns are not aligned during/after resizing.
And I am wondering if this is possible. If you have any ideas on the subject or successful implementation, please share.
Here is my sandbox https://codesandbox.io/s/react-table-full-width-resizable-table-virtualized-rows-rqdsr
P.S. I did search for hints through the repo issues discussions with no success:
Any help would be greatly appreciated 🙏
Beta Was this translation helpful? Give feedback.
All reactions