How to Customize the Field Drop Axis in a Blazor Pivot Table?
Introduction
By default, when you select a field using the checkbox selection in the field list, it is automatically added to the value axis if the field is of the number type. Otherwise, it is added to the row axis. However, in certain scenarios where this default behavior does not meet your requirements, you may need to customize the drop axis for specific fields. This article explains how to customize the field drop axis in a Blazor Pivot Table component.
Customize the field drop axis
To customize the field drop axis, use the FieldDrop event. This event is triggered whenever a field is dropped onto an axis, allowing you to programmatically modify the field drop axis.
Here is a code example demonstrating how to modify the drop axis for a specific field when it is selected in the field list:
[Index.razor]
<SfPivotView @ref="Pivot" TValue="ProductDetails" ShowFieldList="true">
<PivotViewEvents TValue="ProductDetails" FieldDrop="FieldDrop"></PivotViewEvents>
</SfPivotView>
@code {
public void FieldDrop(FieldDropEventArgs args)
{
if (args.DraggedAxis == "fieldlist" && args.FieldName == "Year")
{
args.DropAxis = "Columns";
}
}
}
In the above code example, when the “Year” field is selected from the field list, its drop axis is changed to column axis. This change means that the field will be placed on the column axis of the pivot table rather than the row axis.
The following GIF illustrates the results of the above code snippet.
GIF
You can refer to this GitHub sample for a practical demonstration of this code snippet.
Conclusion
We hope you enjoyed learning how to customize the field drop axis in a Blazor Pivot Table.
You can also refer to our Blazor 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 Blazor 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!