computeHeaderCellWidth method
Calculates the width of the header cell based on the GridColumn.columnName
.
You can override this method to perform the custom calculation for height.
If you want to calculate the width based on different TextStyle, you can
override this method and call the super method with the required TextStyle.
Set the custom ColumnSizer
to SfDataGrid.columnSizer
property.
class CustomColumnSizer extends ColumnSizer {
@override
double computeHeaderCellWidth(GridColumn column,
TextStyle textStyle) {
TextStyle style = textStyle;
if (column.columnName == 'Name')
style = TextStyle(fontSize: 20, fontStyle: FontStyle.italic);
return super.computeHeaderCellWidth(column, style);
}
}
The auto size is calculated based on default TextStyle of the datagrid.
Implementation
@override
double computeHeaderCellWidth(GridColumn column, TextStyle style) {
style = style.copyWith(fontWeight: FontWeight.bold);
return super.computeHeaderCellWidth(column, style);
}