DxGridColumn.Width Property
Specifies column width in CSS units.
Namespace: DevExpress.Blazor
Assembly: DevExpress.Blazor.v25.1.dll
NuGet Package: DevExpress.Blazor
Declaration
[DefaultValue(null)]
[Parameter]
public string Width { get; set; }
Property Value
Type | Default | Description |
---|---|---|
String | null | The column’s width. |
Remarks
You can specify the Width
property in any relative or absolute units that your browser supports.
Note
If you set the Width
in em
units, the Grid component converts this value from em
to pixels on page load. The Grid does not automatically update the Width
value when the base em
size changes at runtime (due to CSS rules or window resizing).
@inject WeatherForecastService ForecastService
<DxGrid Data="@Data">
<Columns>
<DxGridDataColumn FieldName="Date" DisplayFormat="D" />
<DxGridDataColumn FieldName="TemperatureC" Caption="@("Temp. (\x2103)")" Width="120px" />
<DxGridDataColumn FieldName="TemperatureF" Caption="@("Temp. (\x2109)")" Width="120px" />
<DxGridDataColumn FieldName="Forecast" />
<DxGridDataColumn FieldName="CloudCover" />
</Columns>
</DxGrid>
@code {
object Data { get; set; }
protected override void OnInitialized() {
Data = ForecastService.GetForecast();
}
}
If you do not specify a column’s Width
property explicitly, its value is automatically calculated based on the Grid’s total width, other column widths, borders, and cell spacing. For more information on how this algorithm works in different scenarios, refer to the following topic: Layout Specifics in Blazor Grid.
If there is not enough space to display all Grid columns, columns with unspecified widths can be collapsed. To prevent a column from collapsing, set its MinWidth property to a non-zero value.