wubostc / virtualized-table-for-antd

the virtualized table component for ant design
MIT License
230 stars 48 forks source link

Responsive scroll "X" doesn't work as antd table #129

Closed joseAAlexandre closed 2 years ago

joseAAlexandre commented 2 years ago

Is there a way to make X responsive with column information? The method used by the antd table is not working.

scroll={{ y: 100, x: "max-content", whiteSpace: "nowrap" }}

https://codesandbox.io/s/antd-reproduction-template-forked-7dql75?file=/index.js

wubostc commented 2 years ago

Is that what you want @joseAAlexandre

https://codesandbox.io/s/antd-reproduction-template-forked-4bgs8j?file=/index.js

joseAAlexandre commented 2 years ago

It's working, but the column headers are fixed.

joseAAlexandre commented 2 years ago

This way works perfectly!!

const [vt, setComponent] = useVT(() => ({ scroll: { y: props.scroll.y, } }), []);

setComponent({
  table: ({ style, ...props }) => <table {...props}
    style={{ ...style, width: 'max-content' }}
  />
});

return (
  <Table components={vt}
    {...props} />
);