Skip to main content
All docs
V24.2

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

DxPivotTable.GetFields() Method

Returns a collection of Pivot Table fields.

Namespace: DevExpress.Blazor.PivotTable

Assembly: DevExpress.Blazor.PivotTable.v24.2.dll

NuGet Package: DevExpress.Blazor.PivotTable

#Declaration

C#
public IReadOnlyList<IPivotTableField> GetFields()

#Returns

Type Description
IReadOnlyList<IPivotTableField>

The field collection.

#Remarks

The following code changes the sort order of the Region field in the BeginUpdate/EndUpdate code block:

@rendermode InteractiveServer

<DxButton Click="ChangeRegionSortOrder">Change Region Sort Order</DxButton>
<p/>

<DxPivotTable Data="SalesData"
         @ref="PivotTable">
    <Fields>
        <DxPivotTableField Field="@nameof(SaleInfo.Region)"
                           Area="@PivotTableArea.Row"
                           AreaIndex="0">
        </DxPivotTableField>
        <DxPivotTableField Field="@nameof(Sales.SaleInfo.Country)"
                           Area="@PivotTableArea.Row"
                           SortOrder="@PivotTableSortOrder.Descending"
                           AreaIndex="1" />
        <DxPivotTableField Field="@nameof(Sales.SaleInfo.Date)"
                           GroupInterval="@PivotTableGroupInterval.DateYear"
                           Area="@PivotTableArea.Column"
                           AreaIndex="0" 
                           Caption="Year" />
        <DxPivotTableField Field="@nameof(Sales.SaleInfo.Date)"
                           GroupInterval="@PivotTableGroupInterval.DateQuarter"
                           Area="@PivotTableArea.Column"
                           AreaIndex="1"
                           Caption="Quarter" />
        <DxPivotTableField Field="@nameof(Sales.SaleInfo.Amount)"
                           SortOrder="@PivotTableSortOrder.Ascending"
                           Area="@PivotTableArea.Data"
                           SummaryType="@PivotTableSummaryType.Sum"/>
    </Fields>
</DxPivotTable>

@code {
    IPivot PivotTable { get; set; }
    IEnumerable<SaleInfo> SalesData;
    protected override async Task OnInitializedAsync() {
        SalesData = await Sales.GetSalesAsync();
    }

    void ChangeRegionSortOrder() {
        PivotTable.BeginUpdate();

        PivotTable
            .GetFields()
            .First(f => f.Field == "Region")
            .ChangeSortOrder();

        PivotTable.EndUpdate();
    }
}

#Implements

See Also