Skip to main content

DxGridDataColumn.DisplayFormat Property

Specifies the format string for column values.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v22.2.dll

NuGet Package: DevExpress.Blazor

Declaration

[DefaultValue(null)]
[Parameter]
public string DisplayFormat { get; set; }

Property Value

Type Default Description
String null

The format string.

Remarks

Use the DisplayFormat property to format values displayed in column cells. For information about supported format strings, refer to the following topics:

The code snippet below applies the following formats:

@using Microsoft.EntityFrameworkCore
@inject IDbContextFactory<NorthwindContext> NorthwindContextFactory
@implements IDisposable

<DxGrid Data="GridDataSource">
    <Columns>
        <DxGridDataColumn FieldName="OrderDate" DisplayFormat="d" />
        <DxGridDataColumn FieldName="CustomerName" />
        <DxGridDataColumn FieldName="Country" />
        <DxGridDataColumn FieldName="Freight" DisplayFormat="n2" />
        <DxGridDataColumn FieldName="ExtendedPrice" DisplayFormat="c" />
    </Columns>
</DxGrid>

@code {
    object GridDataSource { get; set; }
    NorthwindContext Northwind { get; set; }

    protected override void OnInitialized() {
        Northwind = NorthwindContextFactory.CreateDbContext();
        GridDataSource = new GridDevExtremeDataSource<Invoice>(Northwind.Invoices);
    }

    public void Dispose() {
        Northwind?.Dispose();
    }
}

Blazor Grid Large Data

The DisplayFormat property also accepts format strings with the {0} placeholder that replaces a column cell value. The format string syntax is below:

<custom text>{0:<format specifier>}<custom text>

  • custom text - any plain text displayed before and after the column value.
  • ‘{0}’ - the placeholder for the column value.
  • format specifier - specifies the value format.

The following code shows possible format strings:

<DxGrid Data="GridDataSource">
    <Columns>
        @* ... *@
        <DxGridDataColumn FieldName="ExtendedPrice" DisplayFormat="c" />
        @* or *@
        <DxGridDataColumn FieldName="ExtendedPrice" DisplayFormat="${0}" />
        @* or *@
        <DxGridDataColumn FieldName="ExtendedPrice" DisplayFormat="my custom text {0:c}" />
    </Columns>
</DxGrid>

Implements

See Also