Articles in this section
Category / Section

How to Apply Value Sorting in Code Behind in Blazor Grid PivotTable?

2 mins read

This article explains how to apply value sorting in the code behind without binding column fields.

Apply value sorting in code behind without binding column fields

In the pivot table, if fields are not bound to the column axis and only exists in the values axis, the pivot table displays only the grand total columns for the bound value fields. To sort these grand total columns, utilize the HeaderText property in the PivotViewValueSortSettings. This property allows setting the header names with delimiters, which are used for value sorting.

Note: To apply value sorting, set the EnableValueSorting property to true.

Below is a code example that demonstrates how to apply value sorting in code without binding column fields.

[Index.razor]

    <SfPivotView TValue="ProductDetails" Height="400" EnableValueSorting=true>
        <PivotViewDataSourceSettings DataSource="@dataSource">
            <PivotViewValueSortSettings HeaderText="Grand Total##Sold Amount" HeaderDelimiter="##" SortOrder=Sorting.Descending></PivotViewValueSortSettings>
        </PivotViewDataSourceSettings>
    </SfPivotView>

In this example, the HeaderText property is set to Grand Total##Sold Amount(i.e., Grand Totals + HeaderDelimiter + value field name), where Grand Total is the header text for the grand total columns and Sold Amount is the name of the value field. The HeaderDelimiter is set to ## to distinguish between the grand total header and the value field name. Finally, the SortOrder property is set to Sorting.Descending to sort the values in descending order.

The following screenshot portrays the results of the code snippet mentioned above,

Screenshot

value-sorting.png

For a practical demonstration, refer to the Blazor Playground sample

Conclusion:

We hope you enjoyed learning how to apply value sorting in code behind without binding column fields.

You can also refer to our Pivot Table feature tour page to learn about its other groundbreaking features, documentation, and how to quickly get started with configuration specifications. You can also explore our Pivot Table example to understand how to create and manipulate data.

For current customers, our Blazor components are available on the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to evaluate our Blazor Pivot Table and other Blazor components.

If you have any questions or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, support portal, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied