Dynamic row height
WHICH VERSION OF REACT ARE YOU USING?
Officially Supported:
[X] v0.14.x
Community Supported:
[ ] v15.0.x
WHICH BROWSER ARE YOU USING?
Officially Supported:
[ ] IE 9 / IE 10 / IE 11
[ ] Edge
[X] Chrome
Should work:
[ ] Firefox
[ ] Safari
I'm submitting a ... (check one with "x")
[ ] bug report
[X] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/adazzle/react-data-grid/blob/master/CONTRIBUTING.md
Current behavior The row height is a fixed value. The height value can be specified through the "rowHeight" property of the ReactDataGrid component. There is no (clear) way to have rows with a variable row height.
Expected/desired behavior The height of the cell (and row) must be automatically changed to the height of the rendered html in the cell.
Reproduction of the problem

What is the motivation / use case for changing the behavior? I want to render html from string in a cell.
For latecomers, i can confirm that it can be easily done by returning <ReactDataGrid.Row height={your_desired_height}/> in the rowRenderer function & implement your own formatter if you have troubles rendering the line break. (split and render each line as a div)
@raymondtam returning <ReactDataGrid.Row height={your_desired_height}/> in the rowRenderer was able to produce rows of different heights but the moment I start to scroll the grid beyond the initial viewport, the grid goes into an infinite loop of re-rendering the rows. Any guidance on overcoming this?
Using version 2.0.69
@vijayrajaram Did you ever get an answer to this or find a work around? I'm running into the same issue.
Edit (January 2018): We weren't able to find an appropriate work around for this and have decided to use react-virtualized instead
I have a need for this as well. Is there a way to overload the scroll function or access the virtualizer to implement something for variable row heights? Maybe in the RowRenderer?
I am also stuck in the same issue !!
I have something that mostly works, but is not great. My implementation does not have many rows and columns so I decided to force overscan
<TableDataGrid
// use overScan to prevent table virtual rows
// this renders all rows without any virtual / rendering on demand
// does not work with columns
overScan={{
colsStart: columnCount,
colsEnd: columnCount,
rowsStart: overScanRows,
rowsEnd: overScanRows,
}}
This worked horizontally, but still had a lot of re-rendering horizontally so I fixed it to always render from the first column by extending the class.
class TableDataGrid extends ReactDataGrid {
render() {
// force viewport columns to always start from zero
// to prevent row re-rendering when scrolling horizontally
if (this.base && this.base.viewport) {
this.base.viewport.getVisibleColStart = () => 0;
}
return super.render();
}
}
On safari it is still has issues with header and body not scrolling together smoothly, but it is at least usable. We are likely going to replace react-data-grid unless we can fix the remaining issues.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please reopen this if you feel it has been incorrectly closed and we will do our best to look into it. Thank you for your contributions.
Anyone is working on this feature ?
Yeah, this shouldn't have been close. Still needs to be looked at.
Is there any solution for re-rendering when scrolling?
Just fyi, seems like this might be fixed in the latest version... I haven't tried in my code yet because we need to upgrade, but I just tried on the example here: https://adazzle.github.io/react-data-grid/docs/examples/render-base-row changing the RowRender to have a variable row height:
const RowRenderer = ({ renderBaseRow, ...props }) => {
const color = props.idx % 2 ? "green" : "blue";
return <div style={{ color }}>{renderBaseRow({...props, height: (((props.idx % 2) + 1) * 40)})}</div>;
};
and it seemed to work
This project is kind of a joke. Every real issue gets closed and nobody looks at it. I get being busy, but don't close real issues without updating us...
Any updates? I need the rows height to be dynamic
Just fyi, seems like this might be fixed in the latest version... I haven't tried in my code yet because we need to upgrade, but I just tried on the example here: https://adazzle.github.io/react-data-grid/docs/examples/render-base-row changing the RowRender to have a variable row height:
const RowRenderer = ({ renderBaseRow, ...props }) => { const color = props.idx % 2 ? "green" : "blue"; return <div style={{ color }}>{renderBaseRow({...props, height: (((props.idx % 2) + 1) * 40)})}</div>; };and it seemed to work
I just gave his example a try in Chrome and when you scroll down the top rows start flickering. Also when I scrolled down slowly it kept trying to take me back to the top of the grid (scroll down slowly and you keep going back to the first few rows).
Where is the fix for the dynamic height of the row ?
how i can set dynamic height of table based on rows ...?
why close? still cant auto height
what the solution for dynamic height of ReactData grid ...?
Still waiting for...
please suggest another library