We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

DataGrid DataGridCell as a Widget

I am facing an issue with Flutter DataGrid for my tables. I want to use a Widget as the cell type for more customization, but the `ColumnWidthMode.fitByCellValue` doesn't account for Widgets. My current workaround is to change the toString value to simulate the height and width of the widget, but this is not accurate and only calculates the largest cell width on initial load, not updating as more rows are loaded on scroll.

What is the solution for this issue?


3 Replies

TP Tamilarasan Paranthaman Syncfusion Team February 8, 2023 07:33 AM UTC

Hi Will,

As of now, SfDataGrid doesn’t have support to calculate the cell height and width based on the widget that is loaded in the cells. We have calculated the header and row cell height based on the value set in the column.columnName and DataGridCell.value. We have already logged the feature request regarding this.  We will implement this feature in any of our upcoming releases.

At the planning stage for every release cycle, we review all open features and identify features for implementation based on specific parameters including product vision, technological feasibility, and customer interest. We will let you know when this feature is implemented. We appreciate your patience and understanding until then. You can follow up with the below feedback for further follow-up,

Feedback Link: https://www.syncfusion.com/feedback/30155/support-to-autofit-the-columns-and-rows-based-on-size-of-the-widget-loaded-in

As of now, we request that you pass the required width or height in the computeCellWidth and computeCellHeight methods for data rows and computeHeaderCellWidth and computeHeaderCellHeight methods for header cells.

We have already provided the detailed information about how the column sizing works in DataGrid in below UG link,

UG Document: https://help.syncfusion.com/flutter/datagrid/columns-sizing



WR Will Roxby February 8, 2023 05:08 PM UTC

Hi Tamilarasan,

Thanks for your feedback. Unfortunately, the requested option to use ColumnSizing won't be suitable for our needs as our cells display dynamic data. We require a workaround for calculating widget sizes. Can you recommend a solution? This is critical for us. Also, do you have an estimated timeline for when a fix will be available?


TP Tamilarasan Paranthaman Syncfusion Team February 9, 2023 06:01 AM UTC


At present, you can only calculate the text size using the relevant methods. To assist you better, could you please provide details on the widget that is being loaded in the cell? Additionally, if you could share an image representation of the DataGrid and your requirements, it would be greatly helpful. We will examine the information and update you with further details.

Live Chat Icon For mobile
Up arrow icon