Class DataGridColumnSizer
Represents a class that handles the sizing for all the GridColumns in the Columns collection in a SfDataGrid control.
Inheritance
Implements
Namespace: Syncfusion.Maui.DataGrid
Assembly: Syncfusion.Maui.DataGrid.dll
Syntax
public class DataGridColumnSizer : Object, IDisposable
Constructors
DataGridColumnSizer()
Initializes a new instance of the
Declaration
public DataGridColumnSizer()
DataGridColumnSizer(SfDataGrid)
Initializes a new instance of the
Declaration
public DataGridColumnSizer(SfDataGrid datagrid)
Parameters
| Type | Name | Description |
|---|---|---|
| SfDataGrid | datagrid | The reference of the SfDataGrid. |
Properties
DataGrid
Gets the current instance of the SfDataGrid.
Declaration
public SfDataGrid DataGrid { get; }
Property Value
| Type | Description |
|---|---|
| SfDataGrid | The current instance of the SfDataGrid. |
Methods
Dispose()
Perform final clean up before it is released from memory.
Declaration
public void Dispose()
GetActualWidth(DataGridColumn, Double)
Gets the final computed width after checking the MaximumWidth,MinimumWidth constraints and sets it to the given column.
Declaration
public double GetActualWidth(DataGridColumn column, double calculatedWidth)
Parameters
| Type | Name | Description |
|---|---|---|
| DataGridColumn | column | A |
| System.Double | calculatedWidth | The previously calculated width value before checking the MaximumWidth and |
Returns
| Type | Description |
|---|---|
| System.Double | Returns the actual width that is set to the |
GetColumnAutoSizeWidth(DataGridColumn)
Gets the width that required to auto-fit the given column based on its both header and cell content.
Declaration
protected virtual double GetColumnAutoSizeWidth(DataGridColumn column)
Parameters
| Type | Name | Description |
|---|---|---|
| DataGridColumn | column | The column for which width has to be calculated. |
Returns
| Type | Description |
|---|---|
| System.Double | Returns the width required to auto-fit the given column based on its both header and cell content. |
GetColumnToFill()
Gets the column which will fill to the remaining view port size in the SfDataGrid.
Declaration
protected virtual DataGridColumn GetColumnToFill()
Returns
| Type | Description |
|---|---|
| DataGridColumn | the column to fill. |
OnColumnPropertyChanged(DataGridColumn, String)
Represents the method that will handle the property changes of DataGridColumn.
Declaration
protected virtual void OnColumnPropertyChanged(DataGridColumn column, string propertyName)
Parameters
| Type | Name | Description |
|---|---|---|
| DataGridColumn | column | A |
| System.String | propertyName | The property name. |
OnComputeCellHeight(DataGridColumn, Object)
Calculates the height of the data row's cells. You can override this method to perform the custom calculation for height.
Declaration
protected virtual double OnComputeCellHeight(DataGridColumn column, object cellValue)
Parameters
| Type | Name | Description |
|---|---|---|
| DataGridColumn | column | The Current Column |
| System.Object | cellValue | The value of the current grid cell. |
Returns
| Type |
|---|
| System.Double |
OnComputeCellWidth(DataGridColumn, String)
Measures and returns the text width based on the cell value.
Declaration
protected virtual double OnComputeCellWidth(DataGridColumn column, string text)
Parameters
| Type | Name | Description |
|---|---|---|
| DataGridColumn | column | current column. |
| System.String | text | current column text. |
Returns
| Type | Description |
|---|---|
| System.Double | Returns the text width based on the cell value. |
OnComputeHeaderCellHeight(String, DataGridColumn)
Calculates the height of the header cells. You can override this method to perform the custom calculation for height.
Declaration
protected virtual double OnComputeHeaderCellHeight(string cellValue, DataGridColumn column = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | cellValue | The value of the HeaderCell |
| DataGridColumn | column | The current column. |
Returns
| Type |
|---|
| System.Double |
OnComputeHeaderCellWidth(String, DataGridColumn)
Calculates the width of the header cells. You can override this method to perform the custom calculation for width.
Declaration
protected virtual double OnComputeHeaderCellWidth(string cellValue, DataGridColumn column = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | cellValue | Value of the header cell. |
| DataGridColumn | column | The current column. |
Returns
| Type | Description |
|---|---|
| System.Double | Returns the width required to auto-fit the given column based on its header content. |
Refresh(Boolean)
Refreshes the GridColumns in the view.
Declaration
public void Refresh(bool needsLayout = true)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | needsLayout | A boolean value specifying whether layout is needed. |
ResetAutoWidth(DataGridColumn)
Resets the auto width for the specified column.
Declaration
public void ResetAutoWidth(DataGridColumn column)
Parameters
| Type | Name | Description |
|---|---|---|
| DataGridColumn | column | The corresponding column to reset the auto width. |
Remarks
The column width is reset to double.Nan, if the column sizing needs to be recalculate based on the data.
Exceptions
| Type | Condition |
|---|---|
| System.InvalidOperationException | Thrown when the column is null. |
SetAutoWidth(DataGridColumn, Double)
Sets the measured cell width to the given column.
Declaration
public void SetAutoWidth(DataGridColumn column, double width)
Parameters
| Type | Name | Description |
|---|---|---|
| DataGridColumn | column | The corresponding column to set Auto width. |
| System.Double | width | The corresponding width set as Auto width. |
Exceptions
| Type | Condition |
|---|---|
| System.InvalidOperationException | Thrown when the column is null. |
SetFillWidthForColumns(Double, IEnumerable<DataGridColumn>)
Sets width for the given columns to fill the remaining view port width.
Declaration
protected virtual void SetFillWidthForColumns(double columnsWidth, IEnumerable<DataGridColumn> columns)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Double | columnsWidth | The width of the columns. |
| System.Collections.Generic.IEnumerable<DataGridColumn> | columns | The collection of remaining |