Back to Devexpress

DxGrid.UnboundColumnData Event

blazor-devexpress-dot-blazor-dot-dxgrid-5948e0ca.md

latest3.3 KB
Original Source

DxGrid.UnboundColumnData Event

Allows you to implement custom logic to obtain unbound column values.

Namespace : DevExpress.Blazor

Assembly : DevExpress.Blazor.v25.2.dll

NuGet Package : DevExpress.Blazor

Declaration

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

Parameters

TypeDescription
GridUnboundColumnDataEventArgs

An object that contains data for this event.

|

Remarks

Handle the UnboundColumnData event to implement custom logic or obtain unbound column values from a custom/external data source.

razor
<DxGrid Data="forecasts" UnboundColumnData="Grid_CustomUnboundColumnData">
    <Columns>
        <DxGridDataColumn FieldName="Date" Caption="Date" />
        <DxGridDataColumn FieldName="TemperatureC" Caption="@("Temperature (\x2103)")" />
        <DxGridDataColumn FieldName="TemperatureF" Caption="@("Temperature (\x2109)")"
                          UnboundType="GridUnboundColumnType.Decimal"
                          UnboundExpression="32 + [TemperatureC] / 0.5556" />
        <DxGridDataColumn FieldName="Summary"
                          UnboundType="GridUnboundColumnType.String" />
    </Columns>
</DxGrid>

@code {
    private WeatherForecast[]? forecasts;

    protected override async Task OnInitializedAsync() {
        forecasts = await ForecastService.GetForecastAsync(DateTime.Now);
    }

    void Grid_CustomUnboundColumnData(GridUnboundColumnDataEventArgs e) {
        if (e.FieldName == "Summary") {
            int temperature = Convert.ToInt32(e.GetRowValue("TemperatureC"));
            e.Value = GetTemperatureString(temperature);
        }
    }

    static string GetTemperatureString(int value) {
        if (value < -10)
            return "Cool";
        if (value >= -10 && value < 5)
            return "Chilly";
        if (value >= 5 && value < 15)
            return "Warm";
        return "Hot";
    }
}

View Example: Create and Edit Unbound Columns

Limitations

  • When you use a Server Mode data source, the Grid does not support unbound columns whose values are populated in the UnboundColumnData event handler. You can create unbound columns whose values are calculated based on the UnboundExpression.
  • When you use a GridDevExtremeDataSource, the Grid does not support unbound columns.

See Also

UnboundExpression

UnboundType

DxGrid Class

DxGrid Members

DevExpress.Blazor Namespace