Back to Devexpress

DxGridColumn.MinWidth Property

blazor-devexpress-dot-blazor-dot-dxgridcolumn-f4b12706.md

latest3.2 KB
Original Source

DxGridColumn.MinWidth Property

Specifies a column’s minimum width in pixels.

Namespace : DevExpress.Blazor

Assembly : DevExpress.Blazor.v25.2.dll

NuGet Package : DevExpress.Blazor

Declaration

csharp
[DefaultValue(50)]
[Parameter]
public int MinWidth { get; set; }

Property Value

TypeDefaultDescription
Int3250

A column’s minimum width in pixels.

|

Remarks

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 additional 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.

razor
<DxGrid Data="@Data"
            CssClass="my-class">
        <Columns>
            <DxGridDataColumn FieldName="Date" DisplayFormat="D" Width="200"/>
            <DxGridDataColumn FieldName="Forecast" Width="150" />
            <DxGridDataColumn FieldName="CloudCover" Width="150"/>
            <DxGridDataColumn FieldName="TemperatureC" Caption="@("Temp. (\x2103)")" MinWidth="80"/>
        </Columns>
</DxGrid>

@code {
    object Data { get; set; }

    protected override void OnInitialized() {
        Data = ForecastService.GetForecast().ToList();
    }
}
css
.my-class {
    width: 550px;
}

Set a column’s MinWidth property to 0 to collapse the column when there is not enough space to display it.

razor
<DxGrid Data="@Data"
        CssClass="my-class">
        <Columns>
            <DxGridDataColumn FieldName="Date" DisplayFormat="D" Width="200"/>
            <DxGridDataColumn FieldName="Forecast" Width="150" />
            <DxGridDataColumn FieldName="CloudCover" Width="150"/>
            <DxGridDataColumn FieldName="TemperatureC" Caption="@("Temp. (\x2103)")" MinWidth="0"/>
        </Columns>
</DxGrid>

@code {
    object Data { get; set; }

    protected override void OnInitialized() {
        Data = ForecastService.GetForecast().ToList();
    }
}
css
.my-class {
    width: 500px;
}

Implements

MinWidth

See Also

DxGridColumn Class

DxGridColumn Members

DevExpress.Blazor Namespace