useEffect(() => {
if (!containerRef.current) return;
function autosize() {
gridRef.current?.setColumnSizesToFit();
gridRef.current?.setColumnSizesAuto();
}
const resizeObserver = new ResizeObserver(debounce(autosize, 300));
resizeObserver.observe(containerRef.current);
return () => resizeObserver.disconnect();
}, [
containerRef,
columns,
]);
What you did:
I have a Data Grid that takes 100% the width of the screen. Columns are dynamically set so we can have any number of columns with varying widths. The intended behavior is:
The columns should always fill at least the width of the Data Grid so there is no whitespace
Each column should be at least the width of the column header so the full header is visible
Horizontal scrolling is fine
What happened:
When using setColumnsSizesAuto, if the columns takes up less space than the width of the Data Grid, there is whitespace on the right
When using setColumnSizesToFit, if the width of the Data Grid is smaller than the width of the column headers, then the headers will be truncated with an ellipsis
From a visual perspective, neither setColumnsSizesAuto or setColumnSizesToFit create a consistent looking grid on all screen sizes.
Additionally, there should be a configuration to automatically resize the columns without having to manually call setColumnsSizesAuto and setColumnSizesToFit
Suggested solution:
Either consolidate the functions or create a new one that does the following:
The columns should always fill at least the width of the Data Grid so there is no whitespace
Each column should be at least the width of the column header so the full header is visible
@inovua/reactdatagrid-enterprise
- 5.9.4Relevant code or config https://reactdatagrid.io/docs/autosize-columns
What you did:
I have a Data Grid that takes 100% the width of the screen. Columns are dynamically set so we can have any number of columns with varying widths. The intended behavior is:
What happened:
setColumnsSizesAuto
, if the columns takes up less space than the width of the Data Grid, there is whitespace on the rightsetColumnSizesToFit
, if the width of the Data Grid is smaller than the width of the column headers, then the headers will be truncated with an ellipsisReproduction repository: https://reactdatagrid.io/docs/autosize-columns
Problem description:
setColumnsSizesAuto
orsetColumnSizesToFit
create a consistent looking grid on all screen sizes.setColumnsSizesAuto
andsetColumnSizesToFit
Suggested solution:
Either consolidate the functions or create a new one that does the following: