In our project we control column widths manually as we have complex logic on how wide each column should be, based on a number of external criteria. However, those widths are not fixed and might change during the lifetime of the data grid.
This was not causing any problems up to version 5.11.0 but after we upgraded the Kendo packages this controlled behavior of the column widths broke:
kendo-react-grid v5.11.0 example (working):
https://codesandbox.io/s/crazy-bird-ss7mgl?file=/app/main.tsx
kendo-react-grid latest example (broken):
https://codesandbox.io/s/dazzling-antonelli-wxsflj?file=/app/main.tsx
If we inspect the elements of the data grid, we can see that there is an inline style attribute on the header and body tables, setting the total width of those <table> elements to the sum of its columns. However, that value is not updating after the initial mount as it was prior to v5.12.0 which effectively makes the column widths uncontrollable.
Hello,
The issue is fixed and should be available in the upcoming release.
Regards,
Konstantin Dikov
Progress Telerik
Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Kendo family, check out our getting started resources!
Hi Stoyan,
Thank you for getting back to us.
We understand that updating the key value will have a hit on the performance and it is just a temporary workaround until the issue is resolved. I have logged an item in our repository where you can follow its progress:
Please excuse us for any inconvenience caused by this and if further assistance is needed, do not hesitate to contact us again.
Regards,
Konstantin Dikov
Progress Telerik
Changing the Grid's key will actually remount the whole grid, losing any internal state and causing performance issues with larger tables so it's not a proper workaround. I am pretty confident that the change in behavior is not intentional as I can see the widths of the columns being updated in the markup, but their total is not being recalculated.
Meanwhile if anyone has the same issue, we've found a workaround by setting the width of any <table> in the Grid to "fit-content !important;" via CSS. That probably doesn't work for all use cases, but it works for ours.
Hello Stoyan,
Thank you for contacting us and for providing both examples.
I was able to observe the difference in the behavior in both versions, but I will have to go through the recent fixes and talk with the developers team to see if this was done intentionally. With the latest version there is no "empty" space if the sum of the columns is less than the width of the Grid, which was frequently requested, but I will need some additional time to investigate the case.
Meanwhile, in order to return the previous behavior you can trigger a change in the "key" property of the Grid after setting the new values for the columns width:
const App = () => {
const [firstColW, setFirstColW] = React.useState(500);
const [secondColW, setSecondColW] = React.useState(500);
const [gridKey, setGridKey] = React.useState(new Date());
React.useEffect(() => {
setTimeout(() => {
setFirstColW(300);
setSecondColW(200);
setGridKey(new Date());
}, 3000);
}, []);
return (
<div>
<Grid key={gridKey} style={{ height: "400px" }} data={products}>
Regards,
Konstantin Dikov
Progress Telerik