Skip to main content
A newer version of this page is available. .

DxGrid.UnboundColumnData Event

Specifies data for unbound columns.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v21.1.dll

NuGet Package: DevExpress.Blazor

Declaration

[Parameter]
public Action<GridUnboundColumnDataEventArgs> UnboundColumnData { get; set; }

Parameters

Type Description
GridUnboundColumnDataEventArgs

A GridUnboundColumnDataEventArgs object that contains data for this event.

Remarks

The following example illustrates how to create two unbound columns (“Discontinued” and “Total Price”) and populate them with data. The UnboundColumnData event allows you to evaluate values for unbound column cells.

<DxGrid Data="GridDataSource"
    UnboundColumnData="Grid_CustomUnboundColumnData">
    <Columns>
        <DxGridDataColumn FieldName="ProductId" DisplayFormat="d" />
        <DxGridDataColumn FieldName="UnitPrice" />
        <DxGridDataColumn FieldName="Quantity" />
        <DxGridDataColumn FieldName="Discount" DisplayFormat="p0" />
        <DxGridDataColumn FieldName="Discontinued" UnboundType="GridUnboundColumnType.Boolean">
            <CellDisplayTemplate>
                <DxCheckBox Checked="@((bool)context.Value)" />
            </CellDisplayTemplate>
        </DxGridDataColumn>
        <DxGridDataColumn FieldName="TotalPrice"
                      DisplayFormat="c"
                      UnboundType="GridUnboundColumnType.Decimal" />
    </Columns>
</DxGrid>
@* ... *@
@code {

    object GridDataSource { get; set; }

    protected override void OnInitialized()
    {
        GridDataSource = Northwind.OrderDetails
            .Include(i => i.Product)
            .ToList();
    }

    void Grid_CustomUnboundColumnData(GridUnboundColumnDataEventArgs e)
    {
        if(e.FieldName == "TotalPrice")
        {
            var unitPrice = Convert.ToDecimal(e.GetRowValue("UnitPrice"));
            var quantity = Convert.ToDecimal(e.GetRowValue("Quantity"));
            var discount = Convert.ToDecimal(e.GetRowValue("Discount"));

            e.Value = quantity * unitPrice * (1 - discount);
        }

        if(e.FieldName == "Discontinued")
        {
            e.Value = Convert.ToDecimal(e.GetRowValue("Discount")) == 0;
        }
    }
}

DevExpress Blazor Grid - Unbound Columns

Note

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

See Also