Skip to main content

DxGridDataColumn.UnboundExpression Property

Specifies an expression to evaluate values for the unbound column.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v22.2.dll

NuGet Package: DevExpress.Blazor

Declaration

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

Property Value

Type Default Description
String null

The expression.

Remarks

The following example illustrates how to specify an expression (UnboundExpression) to evaluate the total price for each product and display this value in the “Total Price” unbound column:

@using Microsoft.EntityFrameworkCore
@inject IDbContextFactory<NorthwindContext> NorthwindContextFactory
@implements IDisposable
@* ... *@
<DxGrid Data="GridDataSource">
    <Columns>
        <DxGridDataColumn FieldName="Product.ProductName" Caption="Product Name" />
        <DxGridDataColumn FieldName="UnitPrice" DisplayFormat="c"  />
        <DxGridDataColumn FieldName="Quantity" DisplayFormat="d"  />
        <DxGridDataColumn FieldName="Discount" DisplayFormat="p0" />
        <DxGridDataColumn FieldName="TotalSum"
                          DisplayFormat="c"
                          UnboundType="GridUnboundColumnType.Decimal"
                          UnboundExpression="UnitPrice * Quantity * (1 - Discount)" />
    </Columns>
</DxGrid>

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

    protected override void OnInitialized() {
        Northwind = NorthwindContextFactory.CreateDbContext();
        GridDataSource = Northwind.OrderDetails
            .Include(i => i.Product)
            .ToList();
    }
    @* ... *@
    public void Dispose() {
        Northwind?.Dispose();
    }
}

DevExpress Blazor Grid - Unbound Columns

Note

The Grid does not support unbound columns when you use a GridDevExtremeDataSource.

Implements

See Also