Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

GridRowExportingEventArgs.GetRowValue(String) Method

Returns the value of the specified data field in the current row.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.2.dll

NuGet Package: DevExpress.Blazor

#Declaration

C#
public object GetRowValue(
    string fieldName
)

#Parameters

Name Type Description
fieldName String

The field name.

#Returns

Type Description
Object

The field value.

#Remarks

Call the GetRowValue method to get a value of the specified data field in the current row.

If a group row currently being processed, send the GroupFieldName property value to the GetRowValue method to get the row value. For other fields of a group row, the method returns null.

#Example

The following code snippet exports rows that contain values larger than 1000 in the Total column.

razor
<DxGrid @ref="Grid" Data="@Data" >
    <Columns>
        <DxGridDataColumn FieldName="CompanyName" />
        <DxGridDataColumn FieldName="Country" />
        <DxGridDataColumn FieldName="UnitPrice" DisplayFormat="c" />
        <DxGridDataColumn FieldName="Quantity" />
        <DxGridDataColumn FieldName="Total" UnboundType="GridUnboundColumnType.Integer" 
                          DisplayFormat="c" UnboundExpression="[UnitPrice]*[Quantity]" />
    </Columns>
</DxGrid>
<DxButton Text="Export Big Deals to XLSX" Click="ExportXlsx_Click" />
@code {
    object Data { get; set; }
    IGrid Grid { get; set; }
    protected override async Task OnInitializedAsync() {
        var invoices = await NwindDataService.GetInvoicesAsync();
        var customers = await NwindDataService.GetCustomersAsync();
        Data = invoices.OrderBy(i => i.OrderDate).Join(customers, i => i.CustomerId, c => c.CustomerId, (i, c) => {
            return new {
                OrderDate = i.OrderDate,
                CompanyName = c.CompanyName,
                City = i.City,
                Region = i.Region,
                Country = i.Country,
                UnitPrice = i.UnitPrice,
                Quantity = i.Quantity
            };
        });
    }
    async Task ExportXlsx_Click() {
        var options = new GridXlExportOptions();
        // Exports rows with Total value larger than 1000
        options.RowExporting = e => {
            if (!e.IsGroupRow) {
                if ((int)e.GetRowValue("Total") < 1000) {
                    e.Cancel = true;
                }
            }
        };
       await Grid.ExportToXlsxAsync("Big Deals", options);
    }
}

Grid - Exported big deals

See Also