Our blazing fast Grid component built with pure JavaScript


Post by jq123 »

Hi,

I am using Bryntum Grid v5.5.5 with the React wrapper. I would like to use dynamic row heights for the Grid, so I set autoHeight: true on a column.

const gridConfig = {
       columns: [
  {
                flex: 1,
                field: 'name',
                renderer: (cellData) => <Row cellData={cellData} />, // Renders each cell in the column
                htmlEncodeHeaderText: false,
                htmlEncode: false,
                autoHeight: true, 
                selectionMode: {
                    cell: false,
                },
            },
       ]
}
const [gridData, setGridData] = useState();
const [grid, setGrid] = useState();
const gridRef = useCallback((node) =>setGrid(node));

useEffect(() => {
    grid?.instance.onExpand(() =>{
       // Make an async call
       Api.fetchGridData().then(setGridData);
   }
}, 

return (
            <BryntumGrid
                ref={gridRef}
                collapsed
                collapsible="right"
                data={gridData}
                project={project}
                {...gridConfig}
            />
)

The issue is that autoHeight does not work properly on async loaded data, and the rows are fixed at the default height.

Screenshot 2023-10-25 at 4.53.12 PM.png
Screenshot 2023-10-25 at 4.53.12 PM.png (18.8 KiB) Viewed 988 times

However, when you expand and then collapse the grid, then autoHeight is correctly applied.

Screenshot 2023-10-25 at 4.54.10 PM.png
Screenshot 2023-10-25 at 4.54.10 PM.png (26.33 KiB) Viewed 988 times

I suspect that autoHeight is applied to the rows when the grid is expanded, which is before the Cells are shown on the grid.


Post by Animal »

Must be something else going on that that we can't see.

I just tested the example locally with data loaded remotely and starting collapsed. And when I expand it it shows:

Screenshot 2023-10-26 at 07.39.38.png
Screenshot 2023-10-26 at 07.39.38.png (695.29 KiB) Viewed 977 times

Post by jhill@achieveit.com »

@animal, Could you provide the code or a link to that example? I'm having similar issues getting autoHeight to work as expected.


Post by jhill@achieveit.com »

I was able to find the example, though I'm still having trouble figuring out what I need to do differently. Here is a public repo of the code where I am having the issue: https://github.com/jamesonhill/bryntum-repro. The cell height of the name column is always 46px and causes the text to be cutoff.


Post by jhill@achieveit.com »

Here is a screenshot of what I am seeing

Attachments
Screenshot 2024-01-11 at 4.47.31 PM.png
Screenshot 2024-01-11 at 4.47.31 PM.png (13.27 KiB) Viewed 897 times

Post by ghulam.ghous »

Hi Jhill,

I think the repo link that you shared is private. I am unable to access to it. Can you please check and make it public.

Regards,
Ghous


Post by Animal »

I have reproduced the issue, there's an example with a workaround here: https://codepen.io/Animal-Nige/pen/vYPyEzq?editors=0110


Post by Animal »

OK, that's a subGrid being expanded. That's another event. I will create a Codepen for that case.


Post by Animal »


Post by saki »

Combination of autoHeight and React component renderer is currently not supported. The existing logic for non-react content is that each cell is rendered in the background, its height is measured and then it is set on the row. For React renderer it would be necessary to create and render all necessary React components and measure their heights. This could impair the performance significantly so we currently do not support it.


Post Reply