Skip to main content

GridRowExportingEventArgs.DataItem Property

Returns a data source item that is bound to a row currently being processed.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v23.2.dll

NuGet Package: DevExpress.Blazor

Declaration

public object DataItem { get; }

Property Value

Type Description
Object

If a data row is being exported, the property returns a data item bound to this row. If a group row is being exported, the property returns null.

Remarks

The grid calls the RowExporting action before exporting a data or group row, and allows you to cancel the action.

Use the DataItem property to get a data source item that corresponds to the data row currently being processed. If a group row is being processed, the DataItem property returns null. Use the IsGroupRow property to determine the type of the row.

Pass the DataItem property value to the GetDataItemValue method to get the item’s field value when the Grid is bound to one of the following data sources:

In other cases, you can cast the DataItem property value to the corresponding type and use the {DataItem.FieldName} notation to get the item’s field value.

The code sample below demonstrates how to filter the exported data based on a data item’s property value.

<DxGrid Data="GridData" @ref="Grid" >
    <Columns>
        <DxGridDataColumn FieldName="OrderId" Caption="Order ID" DisplayFormat="d" />
        <DxGridDataColumn FieldName="OrderDate" DisplayFormat="d" />
        <DxGridDataColumn FieldName="ProductName" />
        <DxGridDataColumn FieldName="UnitPrice" DisplayFormat="c2" />
        <DxGridDataColumn FieldName="CustomerName" />
    </Columns>
    <TotalSummary>
        <DxGridSummaryItem SummaryType="GridSummaryItemType.Count" FieldName="CustomerId" />
    </TotalSummary>
</DxGrid>
<DxButton Text="Export unprocessed orders" Click="ExportUnprocessed_Click" />
@code {
    IGrid Grid { get; set; }
    //...
    async Task ExportUnprocessed_Click() {
        var options = new GridXlExportOptions();
        options.RowExporting = e => {
            var order = e.DataItem as Invoice;
            if (order != null) {
                e.Cancel = order.ShippedDate != null;
            }
        };
        await Grid.ExportToXlsxAsync("ExportResult", options);
    }
}

Grid Filtered Export Data

See Also