
Syncfusion Blazor Pivot Table
- 247 installs
- 4 repo stars
- Updated July 28, 2026
- syncfusion/blazor-ui-components-skills
Use syncfusion-blazor-pivot-table for development tasks
About
syncfusion-blazor-pivot-table: A skill for development. This provides functionality for development workflows.
- syncfusion-blazor-pivot-table
Syncfusion Blazor Pivot Table by the numbers
- 247 all-time installs (skills.sh)
- +13 installs in the week ending Aug 5, 2026 (Skillselion tracking)
- Ranked #1,558 of 4,347 Backend & APIs skills by installs in the Skillselion catalog
- Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/syncfusion/blazor-ui-components-skills --skill syncfusion-blazor-pivot-tableAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 247 |
|---|---|
| repo stars | ★ 4 |
| Last updated | July 28, 2026 |
| Repository | syncfusion/blazor-ui-components-skills ↗ |
What it does
Use syncfusion-blazor-pivot-table for development tasks
Files
Syncfusion Blazor Pivot Table
The Syncfusion Blazor Pivot Table (SfPivotView) is a powerful multi-dimensional data analysis component that enables users to organize, summarize, and visualize data across row, column, value, and filter axes — similar to Excel pivot tables. It supports relational data (JSON/IEnumerable) and OLAP cubes, with interactive runtime controls including a Field List and Grouping Bar.
⚠️ Important: Always verify API class names, properties, and method signatures by consulting the reference files in this skill (references/*.md). These are maintained with verified, working examples. Do not assume API details from other sources.⚠️ Security Warning: Data Source Validation
CRITICAL SECURITY NOTICE: When implementing pivot tables, always use trusted data sources. Never fetch or bind data from untrusted or user-provided URLs without proper validation and sanitization.
Security Best Practices:
1. Use Local Data: Prefer local, in-memory data sources for maximum security 2. Validate Remote Sources: Only connect to authenticated and authorized API endpoints under your control 3. Sanitize User Input: Never allow users to specify arbitrary URLs or data sources 4. Implement Authentication: Always use authentication headers and secure API endpoints 5. Content Validation: Validate and sanitize all data received from external sources before binding 6. Use HTTPS: Always use HTTPS for remote data connections 7. Rate Limiting: Implement rate limiting on API endpoints to prevent abuse
Security Risks:
- Indirect Prompt Injection: Untrusted third-party data can contain malicious content that manipulates AI agent behavior
- Data Exfiltration: Malicious data sources could attempt to extract sensitive information
- Code Injection: Untrusted data may contain scripts or harmful content
Recommended Approach:
✅ DO: Use controlled, authenticated backend APIs ✅ DO: Implement server-side data validation ✅ DO: Use configuration files for API endpoints ✅ DO: Whitelist allowed data sources
❌ DON'T: Accept user-provided URLs ❌ DON'T: Bind to public, untrusted endpoints ❌ DON'T: Skip data validation and sanitization ❌ DON'T: Use HTTP for sensitive data
When to Use This Skill
- Implementing
SfPivotViewin a Blazor WASM, Server, or MAUI app - Configuring
PivotViewDataSourceSettingswith JSON, remote, or OLAP data - Using Field List, Grouping Bar, aggregation, or calculated fields
- Applying filtering, sorting, or grouping to pivot data
- Enabling editing, export (Excel/PDF), or toolbar in the Pivot Table
- Rendering a Pivot Chart alongside or instead of the grid
- Optimizing pivot performance with virtual scrolling, paging, or server-side engine
- Applying number/conditional formatting, drill-down, drill-through
- Persisting pivot state or handling pivot events
- Building AI-powered Smart Pivot features
Navigation Guide
Getting Started
📄 Read: references/getting-started.md
- Install NuGet packages, register service, add CSS/JS
- Initialize
SfPivotViewin a Blazor WASM, Server, or MAUI app - Assign sample data and configure row/column/value/filter axes
- Minimal working example
Data Binding
📄 Read: references/data-binding.md
- Bind local JSON/IEnumerable data
- Use
SfDataManagerwithJsonAdaptor,WebApiAdaptor,ODataV4Adaptor - Remote data binding patterns and lazy loading
OLAP Data Source
📄 Read: references/olap.md
- Connect to Microsoft SQL Server Analysis Services (SSAS) OLAP cubes
- Configure OLAP cube elements: hierarchies, measures, dimensions, named sets
- Calculated fields and MDX expressions
- Authentication and role-based access
- OLAP-specific features: field list, grouping bar, virtual scrolling
Connecting to Databases
📄 Read: references/connecting-to-data-sources.md
- Connect to SQL Server, MySQL, PostgreSQL, MongoDB, Oracle, Snowflake, Elasticsearch
- Server-side data service patterns for Blazor
- Connection string setup and adaptor configuration
Field List
📄 Read: references/field-list.md
- Enable built-in (popup) or stand-alone field list
- Customizing fields: captions, visibility, drag behavior
- Defer layout update for batch field changes
Grouping Bar
📄 Read: references/grouping-bar.md
- Enable
ShowGroupingBarfor drag-and-drop field management - Filter, sort, and remove fields at runtime
- Customize grouping bar appearance and behavior
Aggregation
📄 Read: references/aggregation.md
- All
SummaryTypes(Sum, Count, Avg, Min, Max, % of total, etc.) - Set aggregation per value field via
PivotViewValue.Type DifferenceFrom,PercentageOfDifferenceFrom,RunningTotals
Calculated Fields
📄 Read: references/calculated-field.md
- Create formula-based custom fields via UI dialog or
PivotViewCalculatedFieldSettings - Display calculated field in value axis
- Open dialog programmatically
Filtering
📄 Read: references/filtering.md
- Member filtering (include/exclude), label filtering, value filtering
- Programmatic filter setup with
PivotViewFilterSettings - Date filters and OLAP filtering
Sorting
📄 Read: references/sorting.md
- Enable
EnableSortingfor member sort (ascending/descending) - Programmatic sort with
PivotViewSortSettings - Value sorting across column headers
Grouping
📄 Read: references/grouping.md
- Number grouping (ranges), date grouping (year/quarter/month/day), custom grouping
- Enable
AllowGroupingand right-click UI - Programmatic grouping configuration
Drill Down
📄 Read: references/drill-down.md
- Expand/collapse member hierarchies
ExpandAllto show all levels on load- Programmatic drill operations
Drill Through
📄 Read: references/drill-through.md
- Drill-through popup for viewing raw data behind a value cell
Editing
📄 Read: references/editing.md
- Enable
PivotViewCellEditSettingsfor CRUD on raw data - Edit modes: Normal, Dialog, Batch, Command Columns
- Inline editing; add/update/delete with confirmation dialogs
Formatting
📄 Read: references/formatting.md
- Number formatting (N, C, P, custom) via
PivotViewFormatSettings - Conditional formatting with
PivotViewConditionalFormatSettings - Apply formatting via toolbar at runtime
Layout & Display
📄 Read: references/layout-and-display.md
- Component Width/Height, classic layout
- Row/column customization (frozen headers, column width, auto-fit)
- Show/hide grand totals and sub-totals
- Hyper-links in cells, tooltips
Toolbar
📄 Read: references/tool-bar.md
- Enable
ShowToolbarwith built-in items (Grid, Chart, Export, Formatting, Field List) - Custom toolbar items and event handling
- Report management (save, load, rename, delete)
Excel Export
📄 Read: references/excel-export.md
- Excel export:
ExportToExcelAsync, styling, custom file name - CSV export, export as memory stream
- Export via toolbar or programmatically
PDF Export
📄 Read: references/pdf-export.md
- PDF export:
ExportToPdfAsync, page settings, themes - Export chart with table
Performance Optimization
📄 Read: references/performance-best-practices.md
- Virtual scrolling (
EnableVirtualization) for large datasets - Paging (
PivotViewPageSettings) as an alternative to virtualization - Data compression, defer layout update
- WebAssembly-specific optimizations
- Server-side pivot engine for offloading computation
Pivot Chart
📄 Read: references/pivot-chart.md
- Render chart-only, grid-only, or both (
PivotViewDisplayOption) - 15+ chart types via
PivotChartSettings - Drill-down in chart, multiple axes, export chart
State Persistence & Events
📄 Read: references/state-and-events.md
EnablePersistencefor automatic browser local storage- Save/load layout programmatically (
GetPersistDataAsync/LoadPersistDataAsync) - Key events reference:
BeforeColumnsRender,CellClick,DrillThrough,OnLoad
Smart Pivot (AI)
📄 Read: references/smart-pivot.md
Syncfusion.Blazor.AINuGet for AI-powered features- Smart Data Aggregation, Predictive Modeling, Adaptive Filtering
- Configure OpenAI, Azure OpenAI, or Ollama
Quick Start Example
@using Syncfusion.Blazor.PivotView
<SfPivotView TValue="ProductDetails" Height="350">
<PivotViewDataSourceSettings DataSource="@data" EnableSorting="true">
<PivotViewColumns>
<PivotViewColumn Name="Year"></PivotViewColumn>
</PivotViewColumns>
<PivotViewRows>
<PivotViewRow Name="Country"></PivotViewRow>
<PivotViewRow Name="Products"></PivotViewRow>
</PivotViewRows>
<PivotViewValues>
<PivotViewValue Name="Sold" Caption="Units Sold"></PivotViewValue>
<PivotViewValue Name="Amount" Caption="Sold Amount"></PivotViewValue>
</PivotViewValues>
<PivotViewFormatSettings>
<PivotViewFormatSetting Name="Amount" Format="C0" UseGrouping="true"></PivotViewFormatSetting>
</PivotViewFormatSettings>
</PivotViewDataSourceSettings>
</SfPivotView>
@code {
public List<ProductDetails> data { get; set; }
protected override void OnInitialized()
{
data = ProductDetails.GetProductData().ToList();
}
}Common Patterns
Enable Field List + Grouping Bar
<SfPivotView TValue="ProductDetails" ShowFieldList="true" ShowGroupingBar="true">Enable Toolbar with Export
<SfPivotView TValue="ProductDetails" ShowToolbar="true"
Toolbar="@toolbar" AllowExcelExport="true" AllowPdfExport="true">
@code {
public List<ToolbarItems> toolbar = new List<ToolbarItems> {
ToolbarItems.Grid, ToolbarItems.Chart, ToolbarItems.Export,
ToolbarItems.SubTotal, ToolbarItems.GrandTotal, ToolbarItems.FieldList
};
}Virtual Scrolling for Large Data
<SfPivotView TValue="MyData" EnableVirtualization="true" ShowTooltip="false"
Width="100%" Height="500">Show Pivot Chart Only
<SfPivotView TValue="ProductDetails">
<PivotViewDisplayOption View=View.Chart></PivotViewDisplayOption>
<PivotChartSettings Title="Sales Analysis">
<PivotChartSeries Type=ChartSeriesType.Column></PivotChartSeries>
</PivotChartSettings>
</SfPivotView>Key Properties
| Property | Type | Purpose |
|---|---|---|
TValue | Generic | Model type for data rows |
Height / Width | string/int | Component dimensions |
ShowFieldList | bool | Enable popup field list |
ShowGroupingBar | bool | Enable grouping bar |
ShowToolbar | bool | Enable toolbar |
EnableVirtualization | bool | Virtual scrolling |
AllowGrouping | bool | Enable date/number grouping |
AllowCalculatedField | bool | Enable calculated fields |
AllowExcelExport | bool | Enable Excel export |
AllowPdfExport | bool | Enable PDF export |
AllowEditing | bool (in PivotViewCellEditSettings) | Enable CRUD editing |
EnablePersistence | bool | Save state to localStorage |
Aggregation — Syncfusion Blazor Pivot Table
Aggregation determines how numeric values are summarized in Pivot Table cells. By default, values are summed. You can configure per-field aggregation types both programmatically and interactively via the Field List or Grouping Bar.
Note: Aggregation applies to relational data sources only. String, boolean, and date fields support onlyCountandDistinctCount.
Table of Contents
- Available Aggregation Types
- Setting Aggregation Programmatically
- DifferenceFrom and PercentageOfDifferenceFrom
- PercentageOfParentTotal
- Changing Aggregation at Runtime via UI
---
Available Aggregation Types
SummaryTypes Value | Description |
|---|---|
Sum | Total sum (default for numeric fields) |
Count | Number of records |
DistinctCount | Number of unique values |
Avg | Arithmetic mean |
Median | Middle value |
Min | Minimum value |
Max | Maximum value |
Product | Product of all values |
Index | Cell index relative to grand total |
RunningTotals | Cumulative running total |
PopulationStDev | Population standard deviation |
SampleStDev | Sample standard deviation |
PopulationVar | Population variance |
SampleVar | Sample variance |
DifferenceFrom | Difference from a base item in a base field |
PercentageOfDifferenceFrom | % difference from a base item |
PercentageOfGrandTotal | % of grand total |
PercentageOfColumnTotal | % of column total |
PercentageOfRowTotal | % of row total |
PercentageOfParentTotal | % of parent total based on a base field |
PercentageOfParentColumnTotal | % of parent column total |
PercentageOfParentRowTotal | % of parent row total |
CalculatedField | Marks the field as a custom calculated field |
---
Setting Aggregation Programmatically
Set the Type property on PivotViewValue using SummaryTypes:
@using Syncfusion.Blazor.PivotView
<SfPivotView TValue="ProductDetails">
<PivotViewDataSourceSettings DataSource="@data">
<PivotViewColumns>
<PivotViewColumn Name="Year"></PivotViewColumn>
</PivotViewColumns>
<PivotViewRows>
<PivotViewRow Name="Country"></PivotViewRow>
<PivotViewRow Name="Products"></PivotViewRow>
</PivotViewRows>
<PivotViewValues>
<!-- Default: Sum -->
<PivotViewValue Name="Sold" Caption="Units Sold"
Type="SummaryTypes.Sum"></PivotViewValue>
<!-- Average amount -->
<PivotViewValue Name="Amount" Caption="Avg Amount"
Type="SummaryTypes.Avg"></PivotViewValue>
<!-- % of grand total -->
<PivotViewValue Name="Sold" Caption="% of Total"
Type="SummaryTypes.PercentageOfGrandTotal"></PivotViewValue>
</PivotViewValues>
</PivotViewDataSourceSettings>
</SfPivotView>
@code {
public List<ProductDetails> data { get; set; }
protected override void OnInitialized() => data = ProductDetails.GetProductData().ToList();
}---
DifferenceFrom and PercentageOfDifferenceFrom
These types compare each cell value to a specific member in a base field. Configure BaseField and BaseItem:
<PivotViewValues>
<PivotViewValue Name="Amount" Caption="Diff from FY 2022"
Type="SummaryTypes.DifferenceFrom"
BaseField="Year"
BaseItem="FY 2022">
</PivotViewValue>
<PivotViewValue Name="Amount" Caption="% Diff from FY 2022"
Type="SummaryTypes.PercentageOfDifferenceFrom"
BaseField="Year"
BaseItem="FY 2022">
</PivotViewValue>
</PivotViewValues>Use case: Show year-over-year growth by comparing each year's revenue against the baseline year.
---
PercentageOfParentTotal
Shows each cell as a percentage of its parent total. Use BaseField to specify which parent field:
<PivotViewValues>
<PivotViewValue Name="Sold" Caption="% of Country Total"
Type="SummaryTypes.PercentageOfParentTotal"
BaseField="Country">
</PivotViewValue>
</PivotViewValues>---
Changing Aggregation at Runtime via UI
When ShowGroupingBar="true" or ShowFieldList="true", users can change the aggregation type by clicking the value type icon (Σ) on a value field chip. A dropdown appears with all available SummaryTypes.
To allow this, no extra configuration is needed — it's enabled by default when the grouping bar or field list is visible.
To hide the aggregation type icon:
<PivotViewGroupingBarSettings ShowValueTypeIcon="false">
</PivotViewGroupingBarSettings>Calculated Fields — Syncfusion Blazor Pivot Table
Calculated fields let users define custom value fields using mathematical formulas based on existing fields. They appear alongside regular value fields in the Pivot Table. Only applicable to relational data sources.
Table of Contents
- Enable Calculated Fields
- Define a Calculated Field Programmatically
- Open the Calculated Field Dialog via UI
- Open Dialog Programmatically
- Formula Syntax
- Gotchas
---
Enable Calculated Fields
Set AllowCalculatedField="true" on SfPivotView. This also surfaces the CALCULATED FIELD button in the Field List UI.
<SfPivotView TValue="ProductDetails" AllowCalculatedField="true" ShowFieldList="true">---
Define a Calculated Field Programmatically
Use PivotViewCalculatedFieldSettings inside PivotViewDataSourceSettings. The calculated field must also be added to PivotViewValues with Type=SummaryTypes.CalculatedField to appear in the grid.
@using Syncfusion.Blazor.PivotView
<SfPivotView TValue="ProductDetails" ShowFieldList="true" AllowCalculatedField="true">
<PivotViewDataSourceSettings DataSource="@data">
<PivotViewColumns>
<PivotViewColumn Name="Year"></PivotViewColumn>
<PivotViewColumn Name="Quarter"></PivotViewColumn>
</PivotViewColumns>
<PivotViewRows>
<PivotViewRow Name="Country"></PivotViewRow>
<PivotViewRow Name="Products"></PivotViewRow>
</PivotViewRows>
<PivotViewValues>
<PivotViewValue Name="Sold" Caption="Units Sold"></PivotViewValue>
<PivotViewValue Name="Amount" Caption="Sold Amount"></PivotViewValue>
<!-- Calculated field: must be declared here AND in CalculatedFieldSettings -->
<PivotViewValue Name="TotalRevenue" Caption="Total Revenue"
Type="SummaryTypes.CalculatedField">
</PivotViewValue>
</PivotViewValues>
<PivotViewFormatSettings>
<PivotViewFormatSetting Name="Amount" Format="C"></PivotViewFormatSetting>
<PivotViewFormatSetting Name="TotalRevenue" Format="C"></PivotViewFormatSetting>
</PivotViewFormatSettings>
<PivotViewCalculatedFieldSettings>
<PivotViewCalculatedFieldSetting Name="TotalRevenue"
Formula="@formula">
</PivotViewCalculatedFieldSetting>
</PivotViewCalculatedFieldSettings>
</PivotViewDataSourceSettings>
</SfPivotView>
@code {
// Formula: Sum(Amount) + Sum(Sold) — field names wrapped in quotes
public string formula = "\"Sum(Amount)\"" + "+" + "\"Sum(Sold)\"";
public List<ProductDetails> data { get; set; }
protected override void OnInitialized() => data = ProductDetails.GetProductData().ToList();
}---
Open the Calculated Field Dialog via UI
When AllowCalculatedField="true" and ShowFieldList="true", a CALCULATED FIELD button appears at the bottom of the Field List dialog. Clicking it opens an interactive editor where users can:
- Name the new field
- Build formulas by clicking existing fields
- Preview the formula
---
Open Dialog Programmatically
Trigger the dialog from any external button using CreateCalculatedFieldDialogAsync:
@using Syncfusion.Blazor.PivotView
@using Syncfusion.Blazor.Buttons
<SfButton OnClick="OpenDialog">Add Calculated Field</SfButton>
<SfPivotView TValue="ProductDetails" @ref="pivot" AllowCalculatedField="true">
<PivotViewDataSourceSettings DataSource="@data">
...
</PivotViewDataSourceSettings>
</SfPivotView>
@code {
SfPivotView<ProductDetails> pivot;
List<ProductDetails> data = ProductDetails.GetProductData().ToList();
async Task OpenDialog() => await pivot.CreateCalculatedFieldDialogAsync();
}---
Formula Syntax
Formulas use aggregation functions with field names wrapped in double quotes:
| Pattern | Example |
|---|---|
| Simple aggregation | "Sum(Amount)" |
| Multiple fields | "Sum(Amount)" + "Sum(Sold)" |
| Arithmetic | "Sum(Amount)" / "Count(Sold)" |
| Percentage | ("Sum(Sold)" / "Sum(Amount)") * 100 |
In C# string literals, inner quotes must be escaped or use @"..." with doubled quotes:
// Option 1: escape
string formula = "\"Sum(Amount)\" / \"Count(Sold)\"";
// Option 2: verbatim with doubled quotes
string formula = @"""Sum(Amount)"" / ""Count(Sold)""";---
Gotchas
⚠️ Most Common Mistake — Will Silently Break Your Calculated Field:
>
Adding aPivotViewCalculatedFieldSettingis NOT enough on its own. You must also declare the field inPivotViewValueswithType="SummaryTypes.CalculatedField"explicitly set. WithoutType=SummaryTypes.CalculatedField, the field will not render at all — no error is thrown.
>
```razor
<!-- ✅ CORRECT: Both declarations required -->
<PivotViewValues>
<PivotViewValue Name="TotalRevenue" Caption="Total Revenue"
Type="SummaryTypes.CalculatedField"> <!-- ← REQUIRED -->
</PivotViewValue>
</PivotViewValues>
<PivotViewCalculatedFieldSettings>
<PivotViewCalculatedFieldSetting Name="TotalRevenue" Formula="@formula">
</PivotViewCalculatedFieldSetting>
</PivotViewCalculatedFieldSettings>
>
<!-- ❌ WRONG: Missing Type — field won't appear in the grid -->
<PivotViewValue Name="TotalRevenue" Caption="Total Revenue">
</PivotViewValue>
```
- Calculated fields only work with relational data sources, not OLAP
- Field names in formulas are case-sensitive and must exactly match the property names in your data model
- Format settings for the calculated field must be declared separately in
PivotViewFormatSettings
Connecting to Data Sources — Syncfusion Blazor Pivot Table
⚠️ CRITICAL SECURITY NOTICE
All database connections MUST be handled through secure server-side services. This documentation assumes proper security measures are in place:
✅ Required Security Controls:
- Secure connection strings (never exposed to client)
- Proper authentication and authorization
- SQL injection prevention (parameterized queries)
- Input validation and sanitization
- Rate limiting and monitoring
- Encrypted connections (SSL/TLS)
- Principle of least privilege for database access
❌ NEVER:
- Expose connection strings in client code
- Allow direct database access from browser
- Accept user-provided connection strings or queries
- Skip input validation and parameterization
- Use plaintext database connections
Table of Contents
- Overview
- Security Best Practices
- Microsoft SQL Server
- MySQL
- PostgreSQL
- MongoDB
- Oracle
- Snowflake
- Elasticsearch
- Web API Pattern (Recommended for Production)
---
Overview
For connecting databases to the Blazor Pivot Table, the recommended pattern is: 1. Create a Blazor Server or Web API service that queries the database 2. Return data as List<T> or JSON 3. Bind the result to PivotViewDataSourceSettings.DataSource
🔒 Security Requirement: Direct database access from Blazor WASM is not possible and should NEVER be attempted. Always use a server-side service or Web API with proper authentication.
---
Security Best Practices
Database Connection Security
1. Secure Connection Strings
✅ DO: Store in secure configuration
// appsettings.json (server-side only)
{
"ConnectionStrings": {
"SalesDB": "Server=localhost;Database=SalesDB;Integrated Security=True;"
}
}
// Usage
@inject IConfiguration Configuration
string conStr = Configuration.GetConnectionString("SalesDB");❌ DON'T: Hardcode connection strings
// NEVER DO THIS
string conStr = "Server=prod-db;User=admin;Password=secret123;";2. SQL Injection Prevention
✅ DO: Use parameterized queries
string query = "SELECT * FROM Orders WHERE CustomerId = @customerId";
var command = new SqlCommand(query, connection);
command.Parameters.AddWithValue("@customerId", customerId);❌ DON'T: Use string concatenation
// VULNERABLE TO SQL INJECTION
string query = $"SELECT * FROM Orders WHERE CustomerId = '{customerId}'";3. Authentication & Authorization
[Authorize(Roles = "DataAnalyst")]
[HttpGet]
public IActionResult GetPivotData()
{
// Verify user has permission to access this data
if (!User.HasClaim("Permission", "ViewSalesData"))
return Forbid();
// Return data
}4. Input Validation
private bool ValidateInput(string input)
{
// Validate against whitelist
if (string.IsNullOrWhiteSpace(input) || input.Length > 100)
return false;
// Check for suspicious patterns
if (input.Contains("--") || input.Contains(";"))
return false;
return true;
}5. Error Handling
try
{
// Database operations
}
catch (Exception ex)
{
// Log error internally
_logger.LogError(ex, "Database error");
// Return generic error to client (don't expose details)
return StatusCode(500, "An error occurred processing your request");
}---
Microsoft SQL Server
Install: System.Data.SqlClient
@using Syncfusion.Blazor.PivotView
@using System.Data
@using System.Data.SqlClient
<SfPivotView TValue="OrderDetails" Width="800" Height="360">
<PivotViewDataSourceSettings TValue="OrderDetails" DataSource="@dataSource">
<PivotViewColumns>
<PivotViewColumn Name="Product"></PivotViewColumn>
</PivotViewColumns>
<PivotViewRows>
<PivotViewRow Name="Date"></PivotViewRow>
</PivotViewRows>
<PivotViewValues>
<PivotViewValue Name="Amount"></PivotViewValue>
</PivotViewValues>
<PivotViewFormatSettings>
<PivotViewFormatSetting Name="Amount" Format="C2"></PivotViewFormatSetting>
</PivotViewFormatSettings>
</PivotViewDataSourceSettings>
</SfPivotView>
@code {
private List<OrderDetails> dataSource { get; set; }
[Inject]
private IConfiguration Configuration { get; set; }
[Inject]
private ILogger<YourComponent> Logger { get; set; }
protected override void OnInitialized()
{
// 🔒 SECURITY: Use configuration, not hardcoded connection strings
string conStr = Configuration.GetConnectionString("SalesDB");
// 🔒 SECURITY: Use parameterized queries to prevent SQL injection
string query = "SELECT Product, Date, Country, Quantity, Amount FROM Orders WHERE IsActive = @isActive";
try
{
using var connection = new SqlConnection(conStr);
connection.Open();
var command = new SqlCommand(query, connection);
command.Parameters.AddWithValue("@isActive", true);
using var adapter = new SqlDataAdapter(command);
var table = new DataTable();
adapter.Fill(table);
dataSource = (from DataRow row in table.Rows
select new OrderDetails
{
Product = row["Product"].ToString(),
Date = row["Date"].ToString(),
Country = row["Country"].ToString(),
Quantity = Convert.ToInt32(row["Quantity"]),
Amount = Convert.ToDouble(row["Amount"])
}).ToList();
}
catch (Exception ex)
{
// 🔒 SECURITY: Log errors, don't expose to client
Logger.LogError(ex, "Error fetching data from database");
dataSource = new List<OrderDetails>(); // Return empty list on error
}
}
public class OrderDetails
{
public string Product { get; set; }
public string Date { get; set; }
public string Country { get; set; }
public int Quantity { get; set; }
public double Amount { get; set; }
}
}---
MySQL
Install: MySql.Data (or MySqlConnector)
// Program.cs or service class
using MySql.Data.MySqlClient;
string conStr = "Server=localhost;Database=salesdb;User=root;Password=yourpass;";
string query = "SELECT * FROM orders";
using var connection = new MySqlConnection(conStr);
connection.Open();
using var adapter = new MySqlDataAdapter(query, connection);
var table = new DataTable();
adapter.Fill(table);
// Convert DataTable rows to List<OrderDetails> as shown aboveBind the resulting List<T> to DataSource in PivotViewDataSourceSettings.
---
PostgreSQL
Install: Npgsql
using Npgsql;
string conStr = "Host=localhost;Database=salesdb;Username=postgres;Password=yourpass;";
string query = "SELECT * FROM orders";
using var connection = new NpgsqlConnection(conStr);
connection.Open();
using var adapter = new NpgsqlDataAdapter(query, connection);
var table = new DataTable();
adapter.Fill(table);---
MongoDB
Install: MongoDB.Driver
using MongoDB.Driver;
var client = new MongoClient("mongodb://localhost:27017");
var database = client.GetDatabase("salesdb");
var collection = database.GetCollection<OrderDetails>("orders");
// Fetch all documents and convert to list
List<OrderDetails> dataSource = collection.Find(FilterDefinition<OrderDetails>.Empty)
.ToList();Bind dataSource to PivotViewDataSourceSettings.DataSource.
---
Oracle
Install: Oracle.ManagedDataAccess.Core
using Oracle.ManagedDataAccess.Client;
string conStr = "Data Source=localhost/ORCL;User Id=hr;Password=yourpass;";
string query = "SELECT * FROM orders";
using var connection = new OracleConnection(conStr);
connection.Open();
using var adapter = new OracleDataAdapter(query, connection);
var table = new DataTable();
adapter.Fill(table);---
Snowflake
Install: Snowflake.Data
using Snowflake.Data.Client;
string conStr = "account=myaccount;user=myuser;password=mypass;db=SALES;schema=PUBLIC;warehouse=COMPUTE_WH;";
using var connection = new SnowflakeDbConnection { ConnectionString = conStr };
connection.Open();
using var command = connection.CreateCommand();
command.CommandText = "SELECT * FROM ORDERS";
using var reader = command.ExecuteReader();
var dataSource = new List<OrderDetails>();
while (reader.Read())
{
dataSource.Add(new OrderDetails
{
Product = reader["PRODUCT"].ToString(),
Amount = Convert.ToDouble(reader["AMOUNT"]),
// ... map other fields
});
}---
Elasticsearch
Install: NEST (Elasticsearch .NET client)
using Nest;
var settings = new ConnectionSettings(new Uri("http://localhost:9200"))
.DefaultIndex("orders");
var client = new ElasticClient(settings);
var response = client.Search<OrderDetails>(s => s.MatchAll().Size(10000));
List<OrderDetails> dataSource = response.Documents.ToList();---
Web API Pattern (Recommended for Production)
For Blazor WASM or large-scale apps, expose data via a Web API controller and use SfDataManager with WebApiAdaptor:
API Controller (`OrdersController.cs`):
[ApiController]
[Route("api/[controller]")]
public class OrdersController : ControllerBase
{
private readonly IDbService _db;
[HttpGet]
public IActionResult Get() => Ok(_db.GetOrderData());
}Blazor Component:
@using Syncfusion.Blazor.Data
<SfPivotView TValue="OrderDetails" Height="450">
<PivotViewDataSourceSettings TValue="OrderDetails">
<SfDataManager Url="/api/orders"
Adaptor="Syncfusion.Blazor.Adaptors.WebApiAdaptor">
</SfDataManager>
<PivotViewColumns>
<PivotViewColumn Name="Product"></PivotViewColumn>
</PivotViewColumns>
<PivotViewRows>
<PivotViewRow Name="Country"></PivotViewRow>
</PivotViewRows>
<PivotViewValues>
<PivotViewValue Name="Amount"></PivotViewValue>
</PivotViewValues>
</PivotViewDataSourceSettings>
</SfPivotView>Why prefer Web API? It decouples data access from UI, supports caching, authentication, and works with all Blazor hosting models including WASM.
Data Binding — Syncfusion Blazor Pivot Table
⚠️ SECURITY NOTICE
CRITICAL: This documentation contains examples for connecting to remote data sources. Always use trusted, authenticated data sources only. Never bind to untrusted URLs, user-provided endpoints, or public APIs without proper validation and security controls. See the Security Best Practices section below.
Table of Contents
- Security Best Practices
- Local JSON / IEnumerable Binding
- SfDataManager with JsonAdaptor
- Remote Data (WebAPI / OData)
- OLAP Cube Data Source
- Dynamic Data Objects
- ExpandAll on Load
- Refresh Data Programmatically
---
Security Best Practices
Critical Security Guidelines
When implementing data binding for pivot tables, follow these essential security practices:
1. Use Trusted Data Sources Only
✅ RECOMMENDED: Local in-memory data
// Safe: Local data list
public List<ProductDetails> data { get; set; }
protected override void OnInitialized()
{
data = ProductDetails.GetProductData().ToList();
}❌ AVOID: Untrusted remote endpoints
// UNSAFE: Never use arbitrary or user-provided URLs
Url = userProvidedUrl // Security risk!2. Implement Authentication for Remote Sources
If you must use remote data, always use authenticated endpoints:
// Use authenticated API with proper configuration
<SfDataManager Url="@Configuration["ApiEndpoint"]"
Adaptor="Adaptors.WebApiAdaptor"
Headers="@headers">
</SfDataManager>
@code {
private object[] headers = new object[] {
new { Authorization = $"Bearer {AuthToken}" }
};
}3. Validate and Sanitize Data
Always validate data received from external sources:
protected override async Task OnInitializedAsync()
{
var response = await Http.GetFromJsonAsync<List<ProductDetails>>(trustedEndpoint);
// Validate data structure
if (ValidateDataStructure(response))
{
data = SanitizeData(response);
}
}4. Use Configuration Settings
Store API endpoints in configuration, never hardcode:
// appsettings.json
{
"ApiEndpoint": "https://your-trusted-api.com/data",
"AllowedOrigins": ["https://your-domain.com"]
}Security Risks to Avoid
| Risk | Description | Mitigation |
|---|---|---|
| Indirect Prompt Injection | Malicious data manipulating AI behavior | Validate and sanitize all external data |
| Data Exfiltration | Unauthorized access to sensitive data | Use authentication and authorization |
| SSRF Attacks | Server-side request forgery via URLs | Whitelist allowed endpoints |
| XSS via Data | Malicious scripts in data fields | Sanitize and escape all data |
| Credential Exposure | API keys or tokens in code | Use configuration and secure storage |
---
Local JSON / IEnumerable Binding
Assign a List<T> (or any IEnumerable<T>) directly to the DataSource property inside PivotViewDataSourceSettings. This is the default and most common approach.
@using Syncfusion.Blazor.PivotView
<SfPivotView TValue="ProductDetails">
<PivotViewDataSourceSettings DataSource="@data">
<PivotViewColumns>
<PivotViewColumn Name="Year"></PivotViewColumn>
<PivotViewColumn Name="Quarter"></PivotViewColumn>
</PivotViewColumns>
<PivotViewRows>
<PivotViewRow Name="Country"></PivotViewRow>
<PivotViewRow Name="Products"></PivotViewRow>
</PivotViewRows>
<PivotViewValues>
<PivotViewValue Name="Sold" Caption="Unit Sold"></PivotViewValue>
<PivotViewValue Name="Amount" Caption="Sold Amount"></PivotViewValue>
</PivotViewValues>
<PivotViewFormatSettings>
<PivotViewFormatSetting Name="Amount" Format="C"></PivotViewFormatSetting>
</PivotViewFormatSettings>
</PivotViewDataSourceSettings>
</SfPivotView>
@code {
public List<ProductDetails> data { get; set; }
protected override void OnInitialized()
{
data = ProductDetails.GetProductData().ToList();
}
}---
SfDataManager with JsonAdaptor
Use SfDataManager with JsonAdaptor when you need to pass in-memory JSON (e.g., deserialized from an API response) without binding it as a typed list.
@using Syncfusion.Blazor.PivotView
@using Syncfusion.Blazor.Data
<SfPivotView TValue="ProductDetails" Width="1500" Height="300">
<PivotViewDataSourceSettings TValue="ProductDetails" EnableSorting="true">
<SfDataManager Json="@data" Adaptor="Syncfusion.Blazor.Adaptors.JsonAdaptor">
</SfDataManager>
<PivotViewColumns>
<PivotViewColumn Name="Year"></PivotViewColumn>
</PivotViewColumns>
<PivotViewRows>
<PivotViewRow Name="Country"></PivotViewRow>
</PivotViewRows>
<PivotViewValues>
<PivotViewValue Name="Sold" Caption="Units Sold"></PivotViewValue>
</PivotViewValues>
</PivotViewDataSourceSettings>
<PivotViewGridSettings ColumnWidth="120"></PivotViewGridSettings>
</SfPivotView>
@code {
ProductDetails[] data { get; set; }
protected override void OnInitialized()
{
data = ProductDetails.GetProductData().ToArray();
}
}---
Remote Data (WebAPI / OData)
⚠️ SECURITY WARNING: Only use trusted, authenticated endpoints. Never bind to user-provided or untrusted URLs.
Point SfDataManager at a trusted and authenticated API endpoint and choose the appropriate adaptor:
WebApiAdaptor— REST API returning JSONODataV4Adaptor— OData v4 protocolUrlAdaptor— Custom endpoint with Syncfusion query format
@using Syncfusion.Blazor.PivotView
@using Syncfusion.Blazor.Data
@inject IConfiguration Configuration
<SfPivotView TValue="OrderData" Height="450">
<PivotViewDataSourceSettings TValue="OrderData" ExpandAll="false">
<!-- ⚠️ SECURITY: Only use controlled, trusted endpoints -->
<SfDataManager Url="@Configuration["ApiEndpoint"]"
Adaptor="Syncfusion.Blazor.Adaptors.WebApiAdaptor" CrossDomain="true">
</SfDataManager>
<PivotViewColumns>
<PivotViewColumn Name="Year"></PivotViewColumn>
</PivotViewColumns>
<PivotViewRows>
<PivotViewRow Name="ProductName"></PivotViewRow>
</PivotViewRows>
<PivotViewValues>
<PivotViewValue Name="Quantity" Caption="Qty Sold"></PivotViewValue>
<PivotViewValue Name="UnitPrice" Caption="Total Revenue"></PivotViewValue>
</PivotViewValues>
</PivotViewDataSourceSettings>
</SfPivotView>Note: The API must support$filter,$top, and$skipquery parameters for the adaptor to function correctly. For custom APIs, return data in{ result: [], count: N }format withUrlAdaptor.
---
OLAP Cube Data Source
Connect to OLAP cubes (SQL Server Analysis Services, SSAS) using PivotViewOlapDataSourceSettings:
@using Syncfusion.Blazor.PivotView
<SfPivotView TValue="string">
<PivotViewDataSourceSettings TValue="string"
ProviderType="ProviderType.SSAS"
Catalog="Adventure Works DW 2008 SE"
Cube="Adventure Works"
Url="https://demos.syncfusion.com/olap/msmdpump.dll"
LocaleIdentifier="1033" EnableSorting="true">
<PivotViewColumns>
<PivotViewColumn Name="[Product].[Product Categories]" Caption="Product Categories">
</PivotViewColumn>
</PivotViewColumns>
<PivotViewRows>
<PivotViewRow Name="[Customer].[Customer Geography]" Caption="Customer Geography">
</PivotViewRow>
</PivotViewRows>
<PivotViewValues>
<PivotViewValue Name="[Measures].[Customer Count]" Caption="Customer Count">
</PivotViewValue>
<PivotViewValue Name="[Measures].[Internet Sales Amount]" Caption="Internet Sales">
</PivotViewValue>
</PivotViewValues>
</PivotViewDataSourceSettings>
</SfPivotView>Tip: OLAP-specific features like MDX queries and member leveling require the toolbar's MDX option to be enabled via ToolbarItems.MDX.---
Dynamic Data Objects
The Pivot Table supports ExpandoObject and other dynamic types when the schema is not known at compile time:
<SfPivotView TValue="ExpandoObject">
<PivotViewDataSourceSettings DataSource="@data">
...
</PivotViewDataSourceSettings>
</SfPivotView>
@code {
List<ExpandoObject> data = new();
protected override void OnInitialized()
{
dynamic row1 = new ExpandoObject();
row1.Country = "France"; row1.Year = "FY 2023"; row1.Amount = 5000;
data.Add(row1);
// add more rows...
}
}---
ExpandAll on Load
By default, only top-level members are shown. Set ExpandAll="true" to expand all hierarchy levels on initial render:
<PivotViewDataSourceSettings DataSource="@data" ExpandAll="true">Performance note: ExpandAll on large datasets increases initial render time. Prefer expanding specific members programmatically for better UX.---
Refresh Data Programmatically
Using RefreshAsync Method
The RefreshAsync() method provides dynamic and asynchronous refreshing of the Pivot Table. Use it to update the component after programmatic changes to the data source or report configuration.
Method Signature
Task RefreshAsync(bool updateDataSource = false)Parameters:
updateDataSource(bool):true: Full refresh including data re-processing (complete engine rebuild)false: Layout-only refresh (default, faster)
When to Use RefreshAsync
- After programmatically adding/removing fields from axes
- After changing aggregation types or calculated fields
- After modifying filter or sort settings
- When data source properties change
- After updating formatting rules
Full Refresh Example
Use true parameter when the underlying data has changed or when adding/removing fields:
<button @onclick="AddProductField">Add Product to Rows</button>
<SfPivotView @ref="pivotView" TValue="ProductDetails">
<PivotViewDataSourceSettings DataSource="@data">
<PivotViewColumns>
<PivotViewColumn Name="Year"></PivotViewColumn>
</PivotViewColumns>
<PivotViewRows>
<PivotViewRow Name="Country"></PivotViewRow>
</PivotViewRows>
<PivotViewValues>
<PivotViewValue Name="Sold" Caption="Units Sold"></PivotViewValue>
<PivotViewValue Name="Amount" Caption="Sales Amount"></PivotViewValue>
</PivotViewValues>
</PivotViewDataSourceSettings>
</SfPivotView>
@code {
SfPivotView<ProductDetails> pivotView;
List<ProductDetails> data = ProductDetails.GetProductData().ToList();
private async Task AddProductField()
{
// Add new field programmatically
// Note: In practice, you'd manipulate the report configuration
// Full refresh to rebuild the engine with new field
await pivotView.RefreshAsync(true);
}
}Layout Refresh Example
Use false (or omit parameter) for UI-only changes that don't require data reprocessing:
<button @onclick="ChangeFormat">Update Formatting</button>
<SfPivotView @ref="pivotView" TValue="ProductDetails">
<PivotViewDataSourceSettings DataSource="@data">
<!-- configuration -->
</PivotViewDataSourceSettings>
</SfPivotView>
@code {
SfPivotView<ProductDetails> pivotView;
private async Task ChangeFormat()
{
// Modify formatting or other display properties
// Layout refresh only (faster)
await pivotView.RefreshAsync(false);
// or simply: await pivotView.RefreshAsync();
}
}Updating Data and Refreshing
When data changes, refresh to reflect updates:
<button @onclick="LoadNewData">Load Updated Data</button>
<SfPivotView @ref="pivotView" TValue="ProductDetails">
<PivotViewDataSourceSettings DataSource="@data">
<PivotViewColumns>
<PivotViewColumn Name="Year"></PivotViewColumn>
</PivotViewColumns>
<PivotViewRows>
<PivotViewRow Name="Country"></PivotViewRow>
</PivotViewRows>
<PivotViewValues>
<PivotViewValue Name="Sold" Caption="Units Sold"></PivotViewValue>
</PivotViewValues>
</PivotViewDataSourceSettings>
</SfPivotView>
@code {
SfPivotView<ProductDetails> pivotView;
List<ProductDetails> data;
protected override void OnInitialized()
{
data = ProductDetails.GetProductData().ToList();
}
private async Task LoadNewData()
{
// Update data source
data = await FetchLatestDataFromDatabase();
// Full refresh to process new data
await pivotView.RefreshAsync(true);
}
}Performance Considerations
| Refresh Type | Speed | Use When |
|---|---|---|
Full Refresh (true) | Slower | Data changed, fields added/removed, structure modified |
Layout Refresh (false) | Faster | Formatting changes, UI-only updates, display properties |
Best Practice: Use layout refresh (false) when possible for better performance.
Alternative: Data Reassignment Pattern
For simple data updates, you can reassign the data collection to trigger a re-render:
<SfPivotView TValue="ProductDetails" @ref="pivot">
<PivotViewDataSourceSettings DataSource="@data"> ... </PivotViewDataSourceSettings>
</SfPivotView>
<button @onclick="Refresh">Refresh</button>
@code {
SfPivotView<ProductDetails> pivot;
List<ProductDetails> data = ProductDetails.GetProductData().ToList();
void Refresh()
{
// Replace list reference so Blazor detects the change
data = FetchNewData().ToList();
StateHasChanged();
}
}Note: Data reassignment works for simple scenarios. Use RefreshAsync() for complex updates or when you need fine control over the refresh behavior.Drill Down — Syncfusion Blazor Pivot Table
Drill down enables expanding and collapsing hierarchical members (e.g., Year → Quarter, Country → City) in row and column headers. Users can interactively explore data at different levels, and you can programmatically control expansion.
Drill Down and Drill Up
When a field has hierarchical members, expand/collapse icons automatically appear on row and column headers. Click the + icon to drill down (expand children) and the - icon to drill up (collapse).
This feature is built-in and requires no additional configuration when multiple fields are placed on the same axis.
@using Syncfusion.Blazor.PivotView
<SfPivotView TValue="ProductDetails">
<PivotViewDataSourceSettings DataSource="@data">
<PivotViewColumns>
<PivotViewColumn Name="Year"></PivotViewColumn>
<PivotViewColumn Name="Quarter"></PivotViewColumn>
</PivotViewColumns>
<PivotViewRows>
<PivotViewRow Name="Country"></PivotViewRow>
<PivotViewRow Name="Products"></PivotViewRow>
</PivotViewRows>
<PivotViewValues>
<PivotViewValue Name="Sold" Caption="Units Sold"></PivotViewValue>
<PivotViewValue Name="Amount" Caption="Sold Amount"></PivotViewValue>
</PivotViewValues>
</PivotViewDataSourceSettings>
</SfPivotView>
@code {
public List<ProductDetails> data { get; set; }
protected override void OnInitialized() => data = ProductDetails.GetProductData().ToList();
}Expand All on Load
By default, only the top-level members are shown. Set ExpandAll="true" to show all levels expanded from the start:
<PivotViewDataSourceSettings DataSource="@data" ExpandAll="true">Applies to: Relational data sources only.
Expand Specific Members on Load
Use PivotViewDrilledMember inside PivotViewDataSourceSettings to expand only specific members programmatically:
⚠️ `Name` Must Be the Field Name, Not a Member Value:
>
PivotViewDrilledMember.Namerefers to the field name (the property/column name), not a member caption or a modified value like"Year_FY2023". The members to expand go inItems.
<PivotViewDataSourceSettings DataSource="@data">
...
<PivotViewDrilledMembers>
<!-- Pre-expand "FY 2023" under Year column -->
<PivotViewDrilledMember Name="Year" Items="@(new string[] { "FY 2023" })">
</PivotViewDrilledMember>
<!-- Pre-expand "France" under Country row -->
<PivotViewDrilledMember Name="Country" Items="@(new string[] { "France" })">
</PivotViewDrilledMember>
</PivotViewDrilledMembers>
</PivotViewDataSourceSettings>Drill Position (Independent Drill)
Drilling down on a member in one position does not affect the same member name appearing elsewhere. For example, if both FY 2022 and FY 2023 have "Q1" as a child:
- Expanding Q1 under FY 2022 only expands that specific Q1
- Q1 under FY 2023 remains collapsed
This behavior is automatic and cannot be disabled — it ensures precise data focus.
Responding to Drill Operations with Events
Use the OnActionBegin event to detect drill-down and drill-up actions before they execute, and optionally block them:
@using Syncfusion.Blazor.PivotView
<SfPivotView TValue="ProductDetails" ShowGroupingBar="true">
<PivotViewDataSourceSettings DataSource="@data">
<PivotViewColumns>
<PivotViewColumn Name="Year"></PivotViewColumn>
<PivotViewColumn Name="Quarter"></PivotViewColumn>
</PivotViewColumns>
<PivotViewRows>
<PivotViewRow Name="Country"></PivotViewRow>
<PivotViewRow Name="Products"></PivotViewRow>
</PivotViewRows>
<PivotViewValues>
<PivotViewValue Name="Sold" Caption="Units Sold"></PivotViewValue>
<PivotViewValue Name="Amount" Caption="Sold Amount"></PivotViewValue>
</PivotViewValues>
</PivotViewDataSourceSettings>
<PivotViewEvents TValue="ProductDetails" OnActionBegin="ActionBegin">
</PivotViewEvents>
</SfPivotView>
@code {
public List<ProductDetails> data { get; set; }
protected override void OnInitialized() => data = ProductDetails.GetProductData().ToList();
public void ActionBegin(PivotActionBeginEventArgs args)
{
if (args.ActionName == "Drill down")
{
// Handle drill down action
Console.WriteLine("User is drilling down");
// Optionally block the action
// args.Cancel = true;
}
else if (args.ActionName == "Drill up")
{
// Handle drill up action
Console.WriteLine("User is drilling up");
}
}
}The ActionName parameter indicates the drill action:
"Drill down"- User expanded a member"Drill up"- User collapsed a member
Drill Through — Syncfusion Blazor Pivot Table
Drill-through displays the raw underlying records behind an aggregated value cell in a popup data grid, allowing users to inspect detailed transactions that contribute to a summary figure.
Enable Drill Through
Double-clicking the value cell opens the drill-through dialog listing all rows that contribute to that aggregated value.
Enable drill-through:
<SfPivotView TValue="ProductDetails" AllowDrillThrough="true">
...
</SfPivotView>Configure Drill Through Grid
Configure the detail grid columns (optional):
<SfPivotView TValue="ProductDetails" AllowDrillThrough="true">
<PivotViewDataSourceSettings DataSource="@data">
...
</PivotViewDataSourceSettings>
<PivotViewDrillThroughSettings
EnableColumnVirtualization="false">
</PivotViewDrillThroughSettings>
</SfPivotView>Use Cases
Drill-through is ideal for financial reports where analysts need to see the transactions behind a summary figure. It surfaces data without navigating away from the pivot report.
Editing — Syncfusion Blazor Pivot Table
Cell editing lets users add, update, or delete raw data directly through the Pivot Table UI. Double-clicking a value cell opens a detail data grid in a popup showing the underlying records. CRUD operations performed there automatically recalculate pivot aggregates.
Applies to: Relational data sources only.
Table of Contents
- Enable Editing
- Edit Modes
- Normal Mode
- Dialog Mode
- Batch Mode
- Command Columns Mode
- Inline Editing
- Confirmation Dialogs
---
Enable Editing
⚠️ Correct Tag Name — Frequently Confused:
>
The editing configuration tag is `PivotViewCellEditSettings` — NOT PivotViewEditSettings. The incorrect tag does not exist and will silently fail or cause a compile error.>
```razor
<!-- ✅ CORRECT -->
<PivotViewCellEditSettings AllowEditing="true" Mode="EditMode.Normal">
</PivotViewCellEditSettings>
>
<!-- ❌ WRONG — this tag does not exist -->
<PivotViewEditSettings AllowEditing="true">
</PivotViewEditSettings>
```
Add PivotViewCellEditSettings inside SfPivotView:
@using Syncfusion.Blazor.PivotView
<SfPivotView TValue="ProductDetails">
<PivotViewDataSourceSettings DataSource="@data">
<PivotViewColumns>
<PivotViewColumn Name="Year"></PivotViewColumn>
</PivotViewColumns>
<PivotViewRows>
<PivotViewRow Name="Country"></PivotViewRow>
<PivotViewRow Name="Products"></PivotViewRow>
</PivotViewRows>
<PivotViewValues>
<PivotViewValue Name="Sold" Caption="Units Sold"></PivotViewValue>
<PivotViewValue Name="Amount" Caption="Sold Amount"></PivotViewValue>
</PivotViewValues>
</PivotViewDataSourceSettings>
<PivotViewCellEditSettings
AllowAdding="true"
AllowEditing="true"
AllowDeleting="true"
AllowEditOnDblClick="true"
Mode="EditMode.Normal">
</PivotViewCellEditSettings>
</SfPivotView>
@code {
public List<ProductDetails> data { get; set; }
protected override void OnInitialized() => data = ProductDetails.GetProductData().ToList();
}`PivotViewCellEditSettings` properties:
| Property | Default | Purpose |
|---|---|---|
AllowEditing | false | Enable editing existing records |
AllowAdding | false | Enable adding new rows |
AllowDeleting | false | Enable deleting rows |
AllowCommandColumns | false | Show built-in Edit/Delete command buttons per row |
AllowEditOnDblClick | true | Start editing by double-clicking a cell |
AllowInlineEditing | false | Edit directly in the cell (not a popup row) |
ShowConfirmDialog | true | Confirm before saving changes |
ShowDeleteConfirmDialog | false | Confirm before deleting a record |
Mode | EditMode.Normal | Edit mode type |
---
Edit Modes
| Mode | When to use |
|---|---|
EditMode.Normal | Default; one row at a time, selected row becomes editable inline |
EditMode.Dialog | Opens a popup dialog for each edit — cleaner for many fields |
EditMode.Batch | Accumulate multiple edits before saving; best for bulk updates |
EditMode.CommandColumn | Adds Edit/Delete buttons in a dedicated column per row |
---
Normal Mode
One row edits at a time in place:
<PivotViewCellEditSettings AllowEditing="true" AllowAdding="true"
AllowDeleting="true" Mode="EditMode.Normal">
</PivotViewCellEditSettings>---
Dialog Mode
Opens a dialog per row for editing:
<PivotViewCellEditSettings AllowEditing="true" AllowAdding="true"
AllowDeleting="true" Mode="EditMode.Dialog">
</PivotViewCellEditSettings>---
Batch Mode
Queue multiple edits and commit all at once with a single Update click:
<PivotViewCellEditSettings AllowEditing="true" AllowAdding="true"
AllowDeleting="true" Mode="EditMode.Batch">
</PivotViewCellEditSettings>Use case: When users need to modify many records at once (e.g., bulk price adjustments) without triggering a pivot recalculation after each individual edit.
---
Command Columns Mode
Adds dedicated Edit and Delete buttons in each row of the detail grid:
<PivotViewCellEditSettings AllowEditing="true" AllowAdding="true"
AllowDeleting="true" AllowCommandColumns="true"
Mode="EditMode.CommandColumn">
</PivotViewCellEditSettings>---
Inline Editing
Enable direct cell editing without a popup row transition:
<PivotViewCellEditSettings AllowEditing="true" AllowInlineEditing="true">
</PivotViewCellEditSettings>---
Confirmation Dialogs
Show confirmation prompts to prevent accidental changes:
<PivotViewCellEditSettings
AllowEditing="true"
AllowDeleting="true"
ShowConfirmDialog="true" <!-- Confirm before saving -->
ShowDeleteConfirmDialog="true" <!-- Confirm before deleting -->
Mode="EditMode.Normal">
</PivotViewCellEditSettings>Excel Export — Syncfusion Blazor Pivot Table
Excel export allows you to export the pivot table data to Microsoft Excel format with formatting, formulas, and styling preserved.
Excel Export
Enable with AllowExcelExport="true" and call ExportToExcelAsync():
@using Syncfusion.Blazor.PivotView
@using Syncfusion.Blazor.Buttons
<SfButton OnClick="OnExcelExport" Content="Export to Excel"></SfButton>
<SfPivotView TValue="ProductDetails" @ref="pivot" AllowExcelExport="true">
<PivotViewDataSourceSettings DataSource="@data" EnableSorting="true">
<PivotViewColumns>
<PivotViewColumn Name="Year"></PivotViewColumn>
<PivotViewColumn Name="Quarter"></PivotViewColumn>
</PivotViewColumns>
<PivotViewRows>
<PivotViewRow Name="Country"></PivotViewRow>
<PivotViewRow Name="Products"></PivotViewRow>
</PivotViewRows>
<PivotViewValues>
<PivotViewValue Name="Sold" Caption="Units Sold"></PivotViewValue>
<PivotViewValue Name="Amount" Caption="Sold Amount"></PivotViewValue>
</PivotViewValues>
<PivotViewFormatSettings>
<PivotViewFormatSetting Name="Amount" Format="C0" UseGrouping="true">
</PivotViewFormatSetting>
</PivotViewFormatSettings>
</PivotViewDataSourceSettings>
</SfPivotView>
@code {
SfPivotView<ProductDetails> pivot;
public List<ProductDetails> data { get; set; }
protected override void OnInitialized() => data = ProductDetails.GetProductData().ToList();
// false = direct download; true = returns MemoryStream
public void OnExcelExport() => pivot.ExportToExcelAsync(false);
}---
CSV Export
Export as a comma-separated CSV file — useful for further processing in Excel or data pipelines:
<SfButton OnClick="OnCsvExport" Content="Export to CSV"></SfButton>
@code {
// AllowExcelExport must be true for CSV export as well
public void OnCsvExport() => pivot.ExportToCsvAsync(false);
}---
Export as Memory Stream
Pass true to get a MemoryStream instead of downloading — useful for server-side file generation or email attachments:
@code {
public async Task ExportToStream()
{
// Returns MemoryStream — save to disk, email, or upload to storage
MemoryStream stream = await pivot.ExportToExcelAsync(true) as MemoryStream;
// e.g., save to file:
await File.WriteAllBytesAsync("output.xlsx", stream.ToArray());
}
}---
Custom File Name and Settings
Excel export with custom file name
To set a custom file name, create an ExcelExportProperties object and pass it to the export method:
// ✅ CORRECT — pass ExcelExportProperties with FileName
var exportProperties = new ExcelExportProperties { FileName = "MyReport.xlsx" };
await pivot.ExportToExcelAsync(exportProperties);Full example:
@code {
public async Task OnExcelExport()
{
var exportProperties = new ExcelExportProperties
{
FileName = "SalesReport_Q4_2024.xlsx"
};
await pivot.ExportToExcelAsync(exportProperties);
}
}Field List — Syncfusion Blazor Pivot Table
The Field List is a UI panel (similar to Excel's PivotTable Fields pane) that lets users drag fields between row, column, value, and filter axes at runtime, apply sorting and filtering, and configure the Pivot Table layout interactively.
Table of Contents
- In-Built Field List (Popup)
- Stand-Alone Field List (Fixed)
- Defer Layout Update
- Customizing the Field List
- Field List with Grouping Bar
---
In-Built Field List (Popup)
Enable the popup field list by setting ShowFieldList="true" on SfPivotView. A small icon appears in the top-left (or top-right when the grouping bar is enabled) of the Pivot Table — clicking it opens the field list dialog.
@using Syncfusion.Blazor.PivotView
<SfPivotView TValue="ProductDetails" ShowFieldList="true">
<PivotViewDataSourceSettings DataSource="@data">
<PivotViewColumns>
<PivotViewColumn Name="Year"></PivotViewColumn>
<PivotViewColumn Name="Quarter"></PivotViewColumn>
</PivotViewColumns>
<PivotViewRows>
<PivotViewRow Name="Country"></PivotViewRow>
<PivotViewRow Name="Products"></PivotViewRow>
</PivotViewRows>
<PivotViewValues>
<PivotViewValue Name="Sold" Caption="Units Sold"></PivotViewValue>
<PivotViewValue Name="Amount" Caption="Sold Amount"></PivotViewValue>
</PivotViewValues>
<PivotViewFormatSettings>
<PivotViewFormatSetting Name="Amount" Format="C"></PivotViewFormatSetting>
</PivotViewFormatSettings>
</PivotViewDataSourceSettings>
</SfPivotView>
@code {
public List<ProductDetails> data { get; set; }
protected override void OnInitialized() => data = ProductDetails.GetProductData().ToList();
}---
Stand-Alone Field List (Fixed)
Render the field list as a separate SfPivotFieldList component alongside the Pivot Table. This gives a permanent panel layout similar to Excel's default view.
@using Syncfusion.Blazor.PivotView
<div style="display: flex; gap: 16px;">
<SfPivotView TValue="ProductDetails" @ref="pivotRef" Height="530">
<PivotViewDataSourceSettings DataSource="@data" EnableSorting="true">
<PivotViewColumns>
<PivotViewColumn Name="Year"></PivotViewColumn>
</PivotViewColumns>
<PivotViewRows>
<PivotViewRow Name="Country"></PivotViewRow>
<PivotViewRow Name="Products"></PivotViewRow>
</PivotViewRows>
<PivotViewValues>
<PivotViewValue Name="Amount" Caption="Sold Amount"></PivotViewValue>
</PivotViewValues>
</PivotViewDataSourceSettings>
<PivotViewEvents TValue="ProductDetails"
EnginePopulated="@UpdateFieldList">
</PivotViewEvents>
</SfPivotView>
<SfPivotFieldList TValue="ProductDetails" @ref="fieldListRef"
RenderMode="Mode.Fixed" AllowCalculatedField="true">
<PivotFieldListDataSourceSettings DataSource="@data" EnableSorting="true">
<PivotFieldListColumns>
<PivotFieldListColumn Name="Year"></PivotFieldListColumn>
</PivotFieldListColumns>
<PivotFieldListRows>
<PivotFieldListRow Name="Country"></PivotFieldListRow>
</PivotFieldListRows>
<PivotFieldListValues>
<PivotFieldListValue Name="Amount" Caption="Sold Amount"></PivotFieldListValue>
</PivotFieldListValues>
</PivotFieldListDataSourceSettings>
<PivotFieldListEvents TValue="ProductDetails"
EnginePopulated="@UpdatePivotView">
</PivotFieldListEvents>
</SfPivotFieldList>
</div>
@code {
SfPivotView<ProductDetails> pivotRef;
SfPivotFieldList<ProductDetails> fieldListRef;
List<ProductDetails> data = ProductDetails.GetProductData().ToList();
async Task UpdateFieldList(EnginePopulatedEventArgs args)
{
await fieldListRef.UpdateAsync(pivotRef);
}
async Task UpdatePivotView(EnginePopulatedEventArgs args)
{
await fieldListRef.UpdateViewAsync(pivotRef);
}
}Why use stand-alone? It keeps the pivot grid area uncluttered and gives users a persistent panel to configure the report — ideal for analytics dashboards.
---
Defer Layout Update
When users make multiple field changes (drag fields, change aggregations) the Pivot Table re-renders after every action, which can be slow. Enable AllowDeferLayoutUpdate to batch all changes and apply them when the user explicitly clicks the Update button.
<SfPivotView TValue="ProductDetails" AllowDeferLayoutUpdate="true" ShowFieldList="true">
...
</SfPivotView>Or on the stand-alone field list:
<SfPivotFieldList TValue="ProductDetails" AllowDeferLayoutUpdate="true" RenderMode="Mode.Fixed">When to use: Essential for large datasets where each re-render is expensive. Reduces server calls in Blazor Server apps.
---
Customizing the Field List
Hide specific fields from the field list
<PivotViewDataSourceSettings DataSource="@data">
<!-- Field captions rename display name in field list -->
<PivotViewColumn Name="Year" Caption="Fiscal Year"></PivotViewColumn>
</PivotViewDataSourceSettings>Open field list dialog programmatically
<SfPivotView TValue="ProductDetails" @ref="pivot" ShowFieldList="false">
...
</SfPivotView>
<button @onclick="OpenFieldList">Open Field List</button>
@code {
SfPivotView<ProductDetails> pivot;
void OpenFieldList() => pivot.ShowFieldListAsync();
}---
Field List with Grouping Bar
Both can be enabled simultaneously. The field list icon moves to the top-right corner when the grouping bar is visible:
<SfPivotView TValue="ProductDetails"
ShowFieldList="true"
ShowGroupingBar="true">
...
</SfPivotView>Filtering — Syncfusion Blazor Pivot Table
Filtering lets users focus on specific members of their data by including or excluding items from the Pivot Table display. Three filter types are supported: Member, Label, and Value filtering.
Table of Contents
---
Member Filtering
Member filtering shows or hides specific members of a field. Enabled by default via AllowMemberFilter in PivotViewDataSourceSettings.
Via UI
Click the filter icon on a field in the Field List or Grouping Bar. A dialog shows all members with checkboxes to include/exclude.
Programmatically
@using Syncfusion.Blazor.PivotView
<SfPivotView TValue="ProductDetails" ShowGroupingBar="true">
<PivotViewDataSourceSettings DataSource="@data">
<PivotViewColumns>
<PivotViewColumn Name="Year"></PivotViewColumn>
<PivotViewColumn Name="Quarter"></PivotViewColumn>
</PivotViewColumns>
<PivotViewRows>
<PivotViewRow Name="Country"></PivotViewRow>
<PivotViewRow Name="Products"></PivotViewRow>
</PivotViewRows>
<PivotViewValues>
<PivotViewValue Name="Sold" Caption="Units Sold"></PivotViewValue>
<PivotViewValue Name="Amount" Caption="Sold Amount"></PivotViewValue>
</PivotViewValues>
<PivotViewFormatSettings>
<PivotViewFormatSetting Name="Amount" Format="C0" UseGrouping="true">
</PivotViewFormatSetting>
</PivotViewFormatSettings>
<PivotViewFilterSettings>
<!-- Exclude FY 2017 from Year field -->
<PivotViewFilterSetting Name="Year"
Type="FilterType.Exclude"
Items="@(new string[] { "FY 2017" })">
</PivotViewFilterSetting>
<!-- Include only France and Germany -->
<PivotViewFilterSetting Name="Country"
Type="FilterType.Include"
Items="@(new string[] { "France", "Germany" })">
</PivotViewFilterSetting>
</PivotViewFilterSettings>
</PivotViewDataSourceSettings>
</SfPivotView>
@code {
public List<ProductDetails> data { get; set; }
protected override void OnInitialized() => data = ProductDetails.GetProductData().ToList();
}Key properties on `PivotViewFilterSetting`:
Name— the field name to filterType—FilterType.IncludeorFilterType.ExcludeItems— array of member values to include/exclude
---
Label Filtering
Label filtering applies conditions to row/column header text. For example, show only countries whose name begins with "F".
<PivotViewFilterSettings>
<PivotViewFilterSetting Name="Country"
Type="FilterType.Label"
Condition="Operators.BeginWith"
Value1="F">
</PivotViewFilterSetting>
</PivotViewFilterSettings>Available `Operators` for label filtering:
| Operator | Description |
|---|---|
Equals | Exact match |
DoesNotEquals | Not equal |
BeginWith | Starts with |
DoesNotBeginWith | Does not start with |
EndsWith | Ends with |
Contains | Contains substring |
GreaterThan | Alphabetically greater |
LessThan | Alphabetically less |
Between | Between two values (Value1 and Value2) |
---
Value Filtering
Value filtering shows or hides members based on aggregated value conditions. For example, show only countries where total Amount > 100,000.
<PivotViewFilterSettings>
<PivotViewFilterSetting Name="Country"
Type="FilterType.Value"
Measure="Amount"
Condition="Operators.GreaterThan"
Value1="100000">
</PivotViewFilterSetting>
</PivotViewFilterSettings>Measure— the value field to evaluate (matches aPivotViewValue Name)Condition— comparison operator (Equals,GreaterThan,LessThan,Between, etc.)Value1(andValue2forBetween) — threshold values
---
Date Filtering
For date fields, use FilterType.Date combined with date-specific operators:
<PivotViewFilterSettings>
<PivotViewFilterSetting Name="OrderDate"
Type="FilterType.Date"
Condition="Operators.Between"
Value1="2023-01-01"
Value2="2023-12-31">
</PivotViewFilterSetting>
</PivotViewFilterSettings>---
Disable Filtering
Disable member filtering globally
<PivotViewDataSourceSettings DataSource="@data" AllowMemberFilter="false">Disable label filtering globally
<PivotViewDataSourceSettings DataSource="@data" AllowLabelFilter="false">Disable value filtering globally
<PivotViewDataSourceSettings DataSource="@data" AllowValueFilter="false">When all filtering options are disabled, the filter icon will not appear in the Field List or Grouping Bar.
Formatting — Syncfusion Blazor Pivot Table
Table of Contents
- Number Formatting
- Number Formatting via Toolbar at Runtime
- Conditional Formatting
- Conditional Formatting via Toolbar at Runtime
---
Number Formatting
Format how numeric values display in cells using PivotViewFormatSettings inside PivotViewDataSourceSettings. Apply one format setting per value field.
Format codes
| Code | Example Output | Usage |
|---|---|---|
C / C2 | $1,234.56 | Currency (2 decimal places) |
C0 | $1,235 | Currency, no decimals |
N / N2 | 1,234.56 | Number with grouping |
P / P2 | 12.34% | Percentage |
#,##0.00 | 1,234.56 | Custom pattern |
@using Syncfusion.Blazor.PivotView
<SfPivotView TValue="ProductDetails">
<PivotViewDataSourceSettings DataSource="@data">
<PivotViewColumns>
<PivotViewColumn Name="Year"></PivotViewColumn>
</PivotViewColumns>
<PivotViewRows>
<PivotViewRow Name="Country"></PivotViewRow>
<PivotViewRow Name="Products"></PivotViewRow>
</PivotViewRows>
<PivotViewValues>
<PivotViewValue Name="Sold" Caption="Units Sold"></PivotViewValue>
<PivotViewValue Name="Amount" Caption="Sold Amount"></PivotViewValue>
</PivotViewValues>
<PivotViewFormatSettings>
<!-- Currency with thousand separators -->
<PivotViewFormatSetting Name="Amount" Format="C0" UseGrouping="true">
</PivotViewFormatSetting>
<!-- Plain number, 2 decimal places -->
<PivotViewFormatSetting Name="Sold" Format="N2">
</PivotViewFormatSetting>
</PivotViewFormatSettings>
</PivotViewDataSourceSettings>
</SfPivotView>
@code {
public List<ProductDetails> data { get; set; }
protected override void OnInitialized() => data = ProductDetails.GetProductData().ToList();
}Key PivotViewFormatSetting properties
| Property | Purpose |
|---|---|
Name | Field name to format (must match PivotViewValue Name) |
Format | Format string (C, N, P, or custom pattern) |
UseGrouping | Show thousand separators (default: true) |
Currency | Currency code (e.g., "USD", "EUR", "GBP") |
MinimumFractionDigits | Minimum decimal places |
MaximumFractionDigits | Maximum decimal places |
Custom format example
<!-- Show as "1,234.56 USD" -->
<PivotViewFormatSetting Name="Amount" Format="#,##0.00" Currency="USD">
</PivotViewFormatSetting>---
Number Formatting via Toolbar at Runtime
Enable number formatting through the toolbar to let users change formats interactively:
<SfPivotView TValue="ProductDetails" ShowToolbar="true"
Toolbar="@toolbar" AllowNumberFormatting="true">
@code {
public List<ToolbarItems> toolbar = new List<ToolbarItems>
{
ToolbarItems.NumberFormatting
};
}---
Conditional Formatting
Apply CSS-style formatting (background color, font color, font size, font family) to value cells that meet specified conditions. This helps highlight key data points visually.
Programmatic configuration
Use PivotViewConditionalFormatSettings:
<SfPivotView TValue="ProductDetails" AllowConditionalFormatting="true">
<PivotViewDataSourceSettings DataSource="@data">
...
</PivotViewDataSourceSettings>
<PivotViewConditionalFormatSettings>
<!-- Highlight Amount cells > 100000 in green -->
<PivotViewConditionalFormatSetting
Measure="Amount"
Conditions="Condition.GreaterThan"
Value1="100000"
Style="@highStyle">
</PivotViewConditionalFormatSetting>
<!-- Highlight Amount cells < 10000 in red -->
<PivotViewConditionalFormatSetting
Measure="Amount"
Conditions="Condition.LessThan"
Value1="10000"
Style="@lowStyle">
</PivotViewConditionalFormatSetting>
</PivotViewConditionalFormatSettings>
</SfPivotView>
@code {
public List<ProductDetails> data { get; set; }
protected override void OnInitialized() => data = ProductDetails.GetProductData().ToList();
PivotViewStyle highStyle = new PivotViewStyle
{
BackgroundColor = "#9ef59e", // light green
Color = "#004d00", // dark green text
FontSize = "14px",
FontFamily = "Segoe UI"
};
PivotViewStyle lowStyle = new PivotViewStyle
{
BackgroundColor = "#f5a59e", // light red
Color = "#4d0000", // dark red text
FontSize = "14px",
FontFamily = "Segoe UI"
};
}`PivotViewConditionalFormatSetting` properties:
| Property | Purpose |
|---|---|
Measure | Value field name the condition applies to |
Conditions | Comparison (GreaterThan, LessThan, Equals, Between, etc.) |
Value1 | First threshold value |
Value2 | Second value (for Between condition) |
Style | PivotViewStyle object with CSS properties |
ApplyGrandTotals | Apply formatting to grand total cells too |
---
Conditional Formatting via Toolbar at Runtime
<SfPivotView TValue="ProductDetails" ShowToolbar="true"
Toolbar="@toolbar" AllowConditionalFormatting="true">
@code {
public List<ToolbarItems> toolbar = new List<ToolbarItems>
{
ToolbarItems.ConditionalFormatting
};
}Users click the Conditional Formatting toolbar icon to open an interactive dialog where they can create, edit, and delete formatting rules without code.
Getting Started — Syncfusion Blazor Pivot Table
Table of Contents
- Prerequisites
- Installation
- Register Service & Add Resources
- Initialize the Component
- Assign Data and Configure Axes
- Server App Setup
- MAUI Blazor Setup
- Minimal Working Example
---
Prerequisites
- .NET 6 / 7 / 8 / 9 / 10 SDK
- Visual Studio 2022+, VS Code, or .NET CLI
- A Blazor WebAssembly App, Blazor Server App, Blazor Web App, or MAUI Blazor project
---
Installation
Install the NuGet packages:
Visual Studio — Package Manager Console:
Install-Package Syncfusion.Blazor.PivotTable
Install-Package Syncfusion.Blazor.Themesdotnet CLI:
dotnet add package Syncfusion.Blazor.PivotTable
dotnet add package Syncfusion.Blazor.Themes
dotnet restore---
Register Service & Add Resources
_Imports.razor
@using Syncfusion.Blazor
@using Syncfusion.Blazor.PivotViewProgram.cs
using Syncfusion.Blazor;
// Blazor WASM
builder.Services.AddSyncfusionBlazor();
await builder.Build().RunAsync();
// Blazor Server (.NET 6/7)
builder.Services.AddSyncfusionBlazor();wwwroot/index.html (WASM) or App.razor / _Layout.cshtml (Server)
<head>
<link href="_content/Syncfusion.Blazor.Themes/bootstrap5.css" rel="stylesheet" />
<script src="_content/Syncfusion.Blazor.Core/scripts/syncfusion-blazor.min.js"
type="text/javascript"></script>
</head>Available themes:bootstrap5.css,material.css,fluent.css,tailwind.css,fabric.css
Optional Pivot Table script (for advanced features like OLAP or WebAssembly performance):
```html
<script src="_content/Syncfusion.Blazor.PivotTable/scripts/sf-pivotview.min.js"
type="text/javascript"></script>
```
---
Initialize the Component
Add SfPivotView to a .razor page:
@page "/"
@using Syncfusion.Blazor.PivotView
<SfPivotView TValue="ProductDetails" Height="350"></SfPivotView>TValue is the generic type parameter matching your data model class.
---
Assign Data and Configure Axes
The four axes in PivotViewDataSourceSettings:
- Columns — field members displayed as column headers
- Rows — field members displayed as row headers
- Values — numeric fields to aggregate in cells
- Filters — fields available for filtering without display on grid
@page "/"
@using Syncfusion.Blazor.PivotView
<SfPivotView TValue="ProductDetails" Height="350">
<PivotViewDataSourceSettings DataSource="@data" EnableSorting="true">
<PivotViewColumns>
<PivotViewColumn Name="Year"></PivotViewColumn>
<PivotViewColumn Name="Quarter"></PivotViewColumn>
</PivotViewColumns>
<PivotViewRows>
<PivotViewRow Name="Country"></PivotViewRow>
<PivotViewRow Name="Products"></PivotViewRow>
</PivotViewRows>
<PivotViewValues>
<PivotViewValue Name="Sold" Caption="Units Sold"></PivotViewValue>
<PivotViewValue Name="Amount" Caption="Sold Amount"></PivotViewValue>
</PivotViewValues>
<PivotViewFormatSettings>
<PivotViewFormatSetting Name="Amount" Format="C0" UseGrouping="true">
</PivotViewFormatSetting>
</PivotViewFormatSettings>
</PivotViewDataSourceSettings>
</SfPivotView>
@code {
public List<ProductDetails> data { get; set; }
protected override void OnInitialized()
{
data = ProductDetails.GetProductData().ToList();
}
public class ProductDetails
{
public int Sold { get; set; }
public double Amount { get; set; }
public string Country { get; set; }
public string Products { get; set; }
public string Year { get; set; }
public string Quarter { get; set; }
public static List<ProductDetails> GetProductData()
{
return new List<ProductDetails>
{
new ProductDetails { Sold=31, Amount=52824, Country="France", Products="Mountain Bikes", Year="FY 2022", Quarter="Q1" },
new ProductDetails { Sold=51, Amount=86904, Country="France", Products="Mountain Bikes", Year="FY 2022", Quarter="Q2" },
new ProductDetails { Sold=90, Amount=153360, Country="France", Products="Mountain Bikes", Year="FY 2022", Quarter="Q3" },
new ProductDetails { Sold=83, Amount=124422, Country="France", Products="Road Bikes", Year="FY 2022", Quarter="Q1" },
new ProductDetails { Sold=51, Amount=92824, Country="Germany", Products="Mountain Bikes", Year="FY 2022", Quarter="Q1" },
new ProductDetails { Sold=23, Amount=24422, Country="Germany", Products="Road Bikes", Year="FY 2022", Quarter="Q1" },
new ProductDetails { Sold=91, Amount=67824, Country="United States", Products="Mountain Bikes", Year="FY 2022", Quarter="Q1" },
new ProductDetails { Sold=53, Amount=94422, Country="United States", Products="Road Bikes", Year="FY 2022", Quarter="Q1" },
};
}
}
}---
Server App Setup
For Blazor Server apps, the setup is identical to WASM except:
- Resources go in
~/Pages/_Layout.cshtml(.NET 6/7) or~/Components/App.razor(.NET 8+) - Use
builder.Services.AddSyncfusionBlazor()inProgram.cs
For Blazor Web App (.NET 8+), set the render mode for interactivity:
@rendermode InteractiveServer
@* or *@
@rendermode InteractiveWebAssembly---
MAUI Blazor Setup
For MAUI Blazor hybrid apps:
1. Install Syncfusion.Blazor.PivotTable in the MAUI project 2. Register in MauiProgram.cs:
builder.Services.AddSyncfusionBlazor();3. Add CSS in wwwroot/index.html:
<link href="_content/Syncfusion.Blazor.Themes/bootstrap5.css" rel="stylesheet" />4. Use SfPivotView in any .razor component as normal
---
Minimal Working Example
The smallest possible Pivot Table with data:
@using Syncfusion.Blazor.PivotView
<SfPivotView TValue="SalesData" Height="300">
<PivotViewDataSourceSettings DataSource="@data">
<PivotViewColumns>
<PivotViewColumn Name="Year"></PivotViewColumn>
</PivotViewColumns>
<PivotViewRows>
<PivotViewRow Name="Region"></PivotViewRow>
</PivotViewRows>
<PivotViewValues>
<PivotViewValue Name="Revenue"></PivotViewValue>
</PivotViewValues>
</PivotViewDataSourceSettings>
</SfPivotView>
@code {
record SalesData(string Region, string Year, double Revenue);
List<SalesData> data = new()
{
new("North", "FY 2023", 10000),
new("North", "FY 2024", 12000),
new("South", "FY 2023", 8000),
new("South", "FY 2024", 9500),
};
}Grouping Bar — Syncfusion Blazor Pivot Table
The Grouping Bar is a drag-and-drop UI element rendered above the Pivot Table that displays the currently applied row, column, value, and filter fields. Users can rearrange, remove, filter, and sort fields interactively at runtime without needing to write code.
Table of Contents
- Enable Grouping Bar
- What Users Can Do in the Grouping Bar
- Customizing Grouping Bar Behavior
- Show/Hide Specific Buttons
- Grouping Bar with Field List
---
Enable Grouping Bar
Set ShowGroupingBar="true" on SfPivotView:
@using Syncfusion.Blazor.PivotView
<SfPivotView TValue="ProductDetails" ShowGroupingBar="true">
<PivotViewDataSourceSettings DataSource="@data">
<PivotViewColumns>
<PivotViewColumn Name="Year"></PivotViewColumn>
<PivotViewColumn Name="Quarter"></PivotViewColumn>
</PivotViewColumns>
<PivotViewRows>
<PivotViewRow Name="Country"></PivotViewRow>
<PivotViewRow Name="Products"></PivotViewRow>
</PivotViewRows>
<PivotViewValues>
<PivotViewValue Name="Sold" Caption="Units Sold"></PivotViewValue>
<PivotViewValue Name="Amount" Caption="Sold Amount"></PivotViewValue>
</PivotViewValues>
<PivotViewFormatSettings>
<PivotViewFormatSetting Name="Amount" Format="C"></PivotViewFormatSetting>
</PivotViewFormatSettings>
</PivotViewDataSourceSettings>
</SfPivotView>
@code {
public List<ProductDetails> data { get; set; }
protected override void OnInitialized() => data = ProductDetails.GetProductData().ToList();
}---
What Users Can Do in the Grouping Bar
| Interaction | How |
|---|---|
| Rearrange fields | Drag chips between row/column/value/filter drop zones |
| Remove a field | Click the × (remove) icon on a field chip |
| Add a field | Click Fields icon to open field panel, then drag to a zone |
| Filter field members | Click the filter icon on a field chip |
| Sort field members | Click the sort icon on a field chip (ascending/descending) |
| Change aggregation type | Click the aggregation icon on a value field chip |
---
Customizing Grouping Bar Behavior
Use PivotViewGroupingBarSettings inside SfPivotView to control which UI features are available:
<SfPivotView TValue="ProductDetails" ShowGroupingBar="true">
<PivotViewDataSourceSettings DataSource="@data">
...
</PivotViewDataSourceSettings>
<PivotViewGroupingBarSettings
ShowFilterIcon="true"
ShowSortIcon="true"
ShowRemoveIcon="true"
ShowValueTypeIcon="true"
AllowDragAndDrop="true">
</PivotViewGroupingBarSettings>
</SfPivotView>| Property | Default | Purpose |
|---|---|---|
ShowFilterIcon | true | Show filter icon on each field chip |
ShowSortIcon | true | Show sort icon on each field chip |
ShowRemoveIcon | true | Show remove (×) icon on each field chip |
ShowValueTypeIcon | true | Show aggregation type icon on value field chips |
AllowDragAndDrop | true | Allow fields to be dragged between axes |
---
Show/Hide Specific Buttons
Disable all sorting icons in the grouping bar
<PivotViewGroupingBarSettings ShowSortIcon="false">
</PivotViewGroupingBarSettings>Read-only grouping bar (no drag, no remove)
<PivotViewGroupingBarSettings
AllowDragAndDrop="false"
ShowRemoveIcon="false">
</PivotViewGroupingBarSettings>---
Grouping Bar with Field List
The grouping bar and field list work together seamlessly. When both are enabled, the Field List icon moves to the top-right corner of the grouping bar area:
<SfPivotView TValue="ProductDetails"
ShowGroupingBar="true"
ShowFieldList="true">
...
</SfPivotView>Pattern: Enable the grouping bar for users who primarily rearrange existing fields. Add the field list for users who need to add new fields from the data source. Both together give the full Excel-like pivot experience.
Grouping — Syncfusion Blazor Pivot Table
Grouping automatically organizes date, number, and string fields into meaningful categories (e.g., dates into Year/Quarter/Month, numbers into ranges). Grouped fields act as independent fields and can be moved between axes. Applies to relational data sources only.
Table of Contents
---
Enable Grouping
Set AllowGrouping="true" on SfPivotView. Users can then right-click any row/column header in the Pivot Table and select Group or Ungroup.
@using Syncfusion.Blazor.PivotView
<SfPivotView TValue="ProductDetails" ShowGroupingBar="true" AllowGrouping="true">
<PivotViewDataSourceSettings DataSource="@data">
<PivotViewColumns>
<PivotViewColumn Name="Product_ID" Caption="Product ID"></PivotViewColumn>
</PivotViewColumns>
<PivotViewRows>
<PivotViewRow Name="Date" Caption="Date"></PivotViewRow>
</PivotViewRows>
<PivotViewValues>
<PivotViewValue Name="Sold" Caption="Units Sold"></PivotViewValue>
<PivotViewValue Name="Amount" Caption="Sold Amount"></PivotViewValue>
</PivotViewValues>
<PivotViewFormatSettings>
<PivotViewFormatSetting Name="Date" Type="FormatType.DateTime"
Format="dd/MM/yyyy-hh:mm">
</PivotViewFormatSetting>
<PivotViewFormatSetting Name="Amount" Format="C" UseGrouping="true">
</PivotViewFormatSetting>
</PivotViewFormatSettings>
</PivotViewDataSourceSettings>
</SfPivotView>
@code {
public List<ProductDetails> data { get; set; }
protected override void OnInitialized() => data = ProductDetails.GetProductData().ToList();
}Only one type of grouping can be applied to a single field at a time (similar to Excel behavior).
---
Number Grouping
Groups numeric field members into ranges (e.g., Product IDs 1–5, 6–10).
Via UI: Right-click a numeric header → select Group → set start, end, and interval values.
Programmatically:
<PivotViewGroupSettings>
<PivotViewGroupSetting Name="Product_ID" GroupInterval="5"
StartingAt="1" EndingAt="200"
Type="GroupType.Number">
</PivotViewGroupSetting>
</PivotViewGroupSettings>---
Date Grouping
Groups a DateTime field into hierarchical levels such as Year, Quarter, Month, Day, Hours, Minutes, Seconds.
Via UI: Right-click a date/time header → Group → select desired intervals.
Programmatically:
<PivotViewGroupSettings>
<PivotViewGroupSetting Name="Date"
Type="GroupType.Date"
GroupByDate="@dateGroupSettings">
</PivotViewGroupSetting>
</PivotViewGroupSettings>
@code {
// Group by Year and Month
public DateGroup dateGroupSettings = new DateGroup
{
Years = true,
Months = true,
Quarters = false,
Days = false
};
}Available date group levels: Years, Quarters, Months, Days, Hours, Minutes, Seconds
Tip: Date grouping is the most common use case — group a date-of-order field by Year and Quarter to create time-series pivot reports without modifying the underlying data.
---
Custom Grouping
Groups selected members of a field into a custom named category. For example, group "Mountain Bikes" and "Road Bikes" into "Bikes".
Via UI: Select specific row/column members using Ctrl+click → right-click → Group → enter a group name.
Programmatically:
<PivotViewGroupSettings>
<PivotViewGroupSetting Name="Products"
Type="GroupType.Custom"
CustomGroups="@customGroups">
</PivotViewGroupSetting>
</PivotViewGroupSettings>
@code {
List<CustomGroups> customGroups = new List<CustomGroups>
{
new CustomGroups
{
GroupName = "Bikes",
Items = new string[] { "Mountain Bikes", "Road Bikes" }
}
};
}---
Programmatic Grouping Configuration
Full example combining multiple settings:
<SfPivotView TValue="ProductDetails" AllowGrouping="true">
<PivotViewDataSourceSettings DataSource="@data">
<PivotViewColumns>
<PivotViewColumn Name="Date"></PivotViewColumn>
</PivotViewColumns>
<PivotViewRows>
<PivotViewRow Name="Product_ID"></PivotViewRow>
</PivotViewRows>
<PivotViewValues>
<PivotViewValue Name="Amount"></PivotViewValue>
</PivotViewValues>
<PivotViewFormatSettings>
<PivotViewFormatSetting Name="Date" Type="FormatType.DateTime"
Format="dd/MM/yyyy">
</PivotViewFormatSetting>
</PivotViewFormatSettings>
<PivotViewGroupSettings>
<!-- Group date by year and quarter -->
<PivotViewGroupSetting Name="Date" Type="GroupType.Date"
GroupByDate="@dateGroup">
</PivotViewGroupSetting>
<!-- Group Product IDs into ranges of 10 -->
<PivotViewGroupSetting Name="Product_ID" GroupInterval="10"
StartingAt="1" EndingAt="100" Type="GroupType.Number">
</PivotViewGroupSetting>
</PivotViewGroupSettings>
</PivotViewDataSourceSettings>
</SfPivotView>
@code {
public List<ProductDetails> data { get; set; }
protected override void OnInitialized() => data = ProductDetails.GetProductData().ToList();
DateGroup dateGroup = new DateGroup { Years = true, Quarters = true };
}Layout & Display — Syncfusion Blazor Pivot Table
Table of Contents
- Width and Height
- Classic (Tabular) Layout
- Row & Column Customization
- Show or Hide Totals
- Hyperlinks in Cells
- Tooltip
---
Width and Height
Set dimensions using pixel values, percentages, or auto:
<!-- Fixed pixel size -->
<SfPivotView TValue="ProductDetails" Width="800" Height="400">
<!-- Responsive: fill container width -->
<SfPivotView TValue="ProductDetails" Width="100%" Height="500px">
<!-- Auto height: expands with content, parent scrolls -->
<SfPivotView TValue="ProductDetails" Width="100%" Height="auto">Minimum width is 400px — values below this are ignored.
---
Classic (Tabular) Layout
The default layout is compact (hierarchical, indented). The classic/tabular layout places each row field in its own separate column, resembling a flat table — useful for exporting or when users prefer Excel-style pivot views.
Limitation: Classic layout works only with relational data sources and the client-side engine.
@using Syncfusion.Blazor.PivotView
<SfPivotView TValue="ProductDetails" Height="450" Width="100%">
<PivotViewDataSourceSettings DataSource="@data">
<PivotViewColumns>
<PivotViewColumn Name="Year"></PivotViewColumn>
<PivotViewColumn Name="Quarter"></PivotViewColumn>
</PivotViewColumns>
<PivotViewRows>
<PivotViewRow Name="Country"></PivotViewRow>
<PivotViewRow Name="Products"></PivotViewRow>
</PivotViewRows>
<PivotViewValues>
<PivotViewValue Name="Sold" Caption="Units Sold"></PivotViewValue>
<PivotViewValue Name="Amount" Caption="Sold Amount"></PivotViewValue>
</PivotViewValues>
</PivotViewDataSourceSettings>
<!-- Enable classic/tabular layout -->
<PivotViewGridSettings Layout="PivotLayout.Tabular"></PivotViewGridSettings>
</SfPivotView>
@code {
public List<ProductDetails> data { get; set; }
protected override void OnInitialized() => data = ProductDetails.GetProductData().ToList();
}PivotLayout options:
PivotLayout.Compact— default hierarchical viewPivotLayout.Tabular— classic/tabular (each row field in its own column)
---
Row & Column Customization
Column width
<PivotViewGridSettings ColumnWidth="120"></PivotViewGridSettings>Freeze rows and columns (sticky headers)
<PivotViewGridSettings FrozenRows="2" FrozenColumns="1"></PivotViewGridSettings>Auto-fit columns
<PivotViewGridSettings AllowAutoResizing="true"></PivotViewGridSettings>Row height
<PivotViewGridSettings RowHeight="36"></PivotViewGridSettings>---
Show or Hide Totals
Control grand totals and sub-totals in PivotViewDataSourceSettings:
<!-- Hide all grand totals -->
<PivotViewDataSourceSettings DataSource="@data" ShowGrandTotals="false">
<!-- Hide only row grand totals -->
<PivotViewDataSourceSettings DataSource="@data" ShowRowGrandTotals="false">
<!-- Hide only column grand totals -->
<PivotViewDataSourceSettings DataSource="@data" ShowColumnGrandTotals="false">
<!-- Hide all sub-totals -->
<PivotViewDataSourceSettings DataSource="@data" ShowSubTotals="false">
<!-- Hide row sub-totals only -->
<PivotViewDataSourceSettings DataSource="@data" ShowRowSubTotals="false">All totals are shown by default (true). Hiding them reduces visual clutter in reports with many nested levels.---
Hyperlinks in Cells
Render cells as clickable hyperlinks and handle them via the HyperlinkCellClick event:
<SfPivotView TValue="ProductDetails">
<PivotViewDataSourceSettings DataSource="@data">
...
</PivotViewDataSourceSettings>
<!-- Enable hyperlinks on value cells only -->
<PivotViewHyperlinkSettings ShowValueCellHyperlink="true"
CssClass="e-custom-hyperlink">
</PivotViewHyperlinkSettings>
<PivotViewEvents TValue="ProductDetails"
HyperlinkCellClick="OnHyperlinkClick">
</PivotViewEvents>
</SfPivotView>
@code {
public List<ProductDetails> data { get; set; }
protected override void OnInitialized() => data = ProductDetails.GetProductData().ToList();
void OnHyperlinkClick(HyperCellClickEventArgs args)
{
// args.CurrentCell contains the clicked cell info
Console.WriteLine($"Clicked: {args.CurrentCell.Value}");
}
}`PivotViewHyperlinkSettings` properties:
| Property | Purpose |
|---|---|
ShowHyperlink | Enable links on all cells |
ShowRowHeaderHyperlink | Links only on row headers |
ShowColumnHeaderHyperlink | Links only on column headers |
ShowValueCellHyperlink | Links only on value cells |
ShowSummaryCellHyperlink | Links only on summary/total cells |
HeaderText | Enable link on a specific header text value |
CssClass | Custom CSS class for styling the links |
---
Tooltip
Tooltips show contextual information (row/column headers + value) when hovering over value cells. Enabled by default.
<!-- Show tooltip (default: true) -->
<SfPivotView TValue="ProductDetails" ShowTooltip="true">
<!-- Disable tooltip for better performance on large datasets -->
<SfPivotView TValue="ProductDetails" ShowTooltip="false">Performance tip: Disable tooltips (ShowTooltip="false") when usingEnableVirtualization="true"— toggling the tooltip on large virtualized datasets can cause minor re-render overhead.
OLAP Data Source — Syncfusion Blazor Pivot Table
⚠️ SECURITY NOTICE
All OLAP connections MUST use authenticated, enterprise-managed OLAP servers. Never connect to untrusted OLAP endpoints.
✅ Required Security Controls:
- Enterprise OLAP server authentication
- Role-based access control (RBAC)
- Encrypted connections (HTTPS/SSL)
- Configuration-based endpoints (IConfiguration)
Table of Contents
- Overview
- Getting Started with OLAP
- OLAP Data Binding
- OLAP Cube Elements
- Adding Cube Elements to Axes
- Measures in Row Axis
- Named Sets
- Calculated Fields
- Authentication
- Roles
- Field List with OLAP
- Grouping Bar with OLAP
- Filter Axis
- Virtual Scrolling with OLAP
- OLAP Cube Elements Reference
---
Overview
The Syncfusion Blazor Pivot Table supports OLAP (Online Analytical Processing) data sources, enabling users to analyze multidimensional data from OLAP cubes like Microsoft SQL Server Analysis Services (SSAS). OLAP provides powerful capabilities for complex data analysis, including hierarchies, calculated members, named sets, and MDX expressions.
When to Use OLAP:
- Connecting to Microsoft SQL Server Analysis Services (SSAS)
- Working with multidimensional cubes
- Analyzing data with complex hierarchies
- Using pre-defined calculated measures and dimensions
- Leveraging named sets and MDX expressions
---
Getting Started with OLAP
Basic OLAP Connection
To connect to an OLAP data source, configure PivotViewDataSourceSettings with OLAP-specific properties:
@using Syncfusion.Blazor.PivotView
<SfPivotView TValue="ProductDetails" Width="800" Height="350">
<PivotViewDataSourceSettings TValue="ProductDetails"
ProviderType="ProviderType.SSAS"
Catalog="Adventure Works DW 2008 SE"
Cube="Adventure Works"
Url="https://bi.syncfusion.com/olap/msmdpump.dll"
LocaleIdentifier="1033"
EnableSorting="true">
</PivotViewDataSourceSettings>
</SfPivotView>
@code {
public class ProductDetails
{
public int Sold { get; set; }
public double Amount { get; set; }
public string Country { get; set; }
public string Products { get; set; }
public string Year { get; set; }
public string Quarter { get; set; }
}
}---
OLAP Data Binding
Required Properties
Configure these properties in PivotViewDataSourceSettings to bind OLAP data:
| Property | Type | Description |
|---|---|---|
ProviderType | ProviderType.SSAS | Indicates OLAP provider type |
Url | string | OLAP service URL (msmdpump.dll endpoint) |
Catalog | string | Database/catalog name containing the cube |
Cube | string | Name of the OLAP cube to use |
LocaleIdentifier | int | Optional: Locale ID for formatting (e.g., 1033 for en-US) |
Complete OLAP Binding Example
@using Syncfusion.Blazor.PivotView
<SfPivotView TValue="ProductDetails" Width="800" Height="350">
<PivotViewDataSourceSettings TValue="ProductDetails"
ProviderType="ProviderType.SSAS"
Catalog="Adventure Works DW 2008 SE"
Cube="Adventure Works"
Url="https://bi.syncfusion.com/olap/msmdpump.dll"
LocaleIdentifier="1033"
EnableSorting="true">
<PivotViewColumns>
<PivotViewColumn Name="[Product].[Product Categories]" Caption="Product Category"></PivotViewColumn>
<PivotViewColumn Name="[Measures]" Caption="Measure"></PivotViewColumn>
</PivotViewColumns>
<PivotViewRows>
<PivotViewRow Name="[Customer].[Customer Geography]" Caption="Customer Geography"></PivotViewRow>
</PivotViewRows>
<PivotViewValues>
<PivotViewValue Name="[Measures].[Customer Count]" Caption="Customer Count"></PivotViewValue>
<PivotViewValue Name="[Measures].[Internet Sales Amount]" Caption="Internet Sales Amount"></PivotViewValue>
</PivotViewValues>
<PivotViewFormatSettings>
<PivotViewFormatSetting Name="[Measures].[Internet Sales Amount]" Format="C0"></PivotViewFormatSetting>
</PivotViewFormatSettings>
</PivotViewDataSourceSettings>
<PivotViewGridSettings ColumnWidth="160"></PivotViewGridSettings>
</SfPivotView>---
OLAP Cube Elements
OLAP cubes contain several types of elements that can be used in the Pivot Table:
Element Types
1. Measures: Numeric values for analysis (e.g., Sales Amount, Customer Count) 2. Dimensions: Categorical data (e.g., Product, Customer, Date) 3. Hierarchies: Parent-child relationships within dimensions 4. Levels: Specific stages within hierarchies 5. Named Sets: Predefined groups of members 6. Calculated Members: Custom calculations defined in the cube
OLAP Naming Convention
OLAP cube elements use MDX naming syntax:
[Dimension].[Hierarchy]- Hierarchy reference[Dimension].[Hierarchy].[Level]- Level reference[Measures].[Measure Name]- Measure reference
Example:
[Product].[Product Categories]
[Customer].[Customer Geography]
[Measures].[Internet Sales Amount]---
Adding Cube Elements to Axes
Specifying Cube Elements
Each OLAP cube element must be specified using:
- Name: Unique name from the cube (exact match required)
- Caption: Display label (optional, defaults to Name if not specified)
Four Axes Configuration
<PivotViewDataSourceSettings TValue="ProductDetails"
ProviderType="ProviderType.SSAS"
Catalog="Adventure Works DW 2008 SE"
Cube="Adventure Works"
Url="https://bi.syncfusion.com/olap/msmdpump.dll">
<!-- Columns: Dimensions/Hierarchies displayed as columns -->
<PivotViewColumns>
<PivotViewColumn Name="[Product].[Product Categories]" Caption="Product Category"></PivotViewColumn>
<PivotViewColumn Name="[Measures]" Caption="Measure"></PivotViewColumn>
</PivotViewColumns>
<!-- Rows: Dimensions/Hierarchies displayed as rows -->
<PivotViewRows>
<PivotViewRow Name="[Customer].[Customer Geography]" Caption="Customer Geography"></PivotViewRow>
</PivotViewRows>
<!-- Values: Measures for aggregation -->
<PivotViewValues>
<PivotViewValue Name="[Measures].[Customer Count]" Caption="Customer Count"></PivotViewValue>
<PivotViewValue Name="[Measures].[Internet Sales Amount]" Caption="Internet Sales Amount"></PivotViewValue>
</PivotViewValues>
<!-- Filters: Master filters for the entire table -->
<PivotViewFilters>
<PivotViewFilter Name="[Date].[Fiscal]" Caption="Date Fiscal"></PivotViewFilter>
</PivotViewFilters>
</PivotViewDataSourceSettings>Critical: If the Name does not exactly match the cube element name, the Pivot Table will be empty.---
Measures in Row Axis
By default, measures appear in columns. To display measures in rows:
<PivotViewRows>
<PivotViewRow Name="[Customer].[Customer Geography]" Caption="Customer Geography"></PivotViewRow>
<PivotViewRow Name="[Measures]" Caption="Measures"></PivotViewRow>
</PivotViewRows>Users can also drag the "Measures" button between axes using the grouping bar or field list at runtime.
---
Named Sets
Named sets are predefined MDX expressions that return a group of dimension members.
Using Named Sets
Set IsNamedSet="true" when adding a named set:
<PivotViewColumns>
<PivotViewColumn Name="[Core Product Group]"
Caption="Core Product Group"
IsNamedSet="true"></PivotViewColumn>
<PivotViewColumn Name="[Measures]" Caption="Measures"></PivotViewColumn>
</PivotViewColumns>Named sets can only be added to row or column axes, not to values or filters.
---
Calculated Fields
Create custom calculations based on existing cube elements.
Types of Calculated Fields
1. Calculated Measure: New measure from an expression 2. Calculated Dimension: New dimension from an expression
Defining Calculated Fields in Code
<PivotViewDataSourceSettings TValue="ProductDetails" ProviderType="ProviderType.SSAS"
Catalog="Adventure Works DW 2008 SE"
Cube="Adventure Works"
Url="https://bi.syncfusion.com/olap/msmdpump.dll">
<PivotViewColumns>
<PivotViewColumn Name="[Product].[Product Categories]" Caption="Product Categories"></PivotViewColumn>
<PivotViewColumn Name="[Measures]" Caption="Measures"></PivotViewColumn>
</PivotViewColumns>
<PivotViewRows>
<PivotViewRow Name="[Customer].[Customer Geography]" Caption="Customer Geography"></PivotViewRow>
</PivotViewRows>
<PivotViewValues>
<PivotViewValue Name="[Measures].[Customer Count]" Caption="Customer Count"></PivotViewValue>
<PivotViewValue Name="Order on Discount" IsCalculatedField="true"></PivotViewValue>
</PivotViewValues>
<PivotViewCalculatedFieldSettings>
<!-- Calculated Dimension -->
<PivotViewCalculatedFieldSetting
Name="BikeAndComponents"
Formula="([Product].[Product Categories].[Category].[Bikes] + [Product].[Product Categories].[Category].[Components])"
HierarchyUniqueName="[Product].[Product Categories]"
FormatString="Standard">
</PivotViewCalculatedFieldSetting>
<!-- Calculated Measure -->
<PivotViewCalculatedFieldSetting
Name="Order on Discount"
Formula="[Measures].[Order Quantity] + ([Measures].[Order Quantity] * 0.10)"
FormatString="Currency">
</PivotViewCalculatedFieldSetting>
</PivotViewCalculatedFieldSettings>
</PivotViewDataSourceSettings>Calculated Field Properties
| Property | Description |
|---|---|
Name | Unique name for the calculated field |
Formula | MDX expression for the calculation |
HierarchyUniqueName | Parent hierarchy (for calculated dimensions only) |
FormatString | Display format: Standard, Currency, Percent, or custom |
IsCalculatedField | Set to true when adding to an axis |
Enable Calculated Field UI
Allow users to create calculated fields at runtime:
<SfPivotView TValue="ProductDetails"
ShowFieldList="true"
AllowCalculatedField="true">This adds a "CALCULATED FIELD" button in the field list UI.
Format String Options
- Standard: Display as numbers (e.g., 9584.3)
- Currency: Display with currency symbol (e.g., $9,584.30)
- Percent: Display as percentage (e.g., 95.84%)
- Custom: Define custom format (e.g., "###0.##0#" → 9584.300)
Supported MDX Operators and Functions
Calculated fields support standard MDX operators and functions. See Microsoft documentation:
Example Formula:
IIF([Measures].[Internet Sales Amount]^0.5 > 100,
[Measures].[Internet Sales Amount]*100,
[Measures].[Internet Sales Amount]/100)Note: Calculated measures can only be added to the value axis.
---
Authentication
Provide credentials for secure OLAP connections:
<PivotViewDataSourceSettings TValue="ProductDetails"
ProviderType="ProviderType.SSAS"
Catalog="Adventure Works DW 2008 SE"
Cube="Adventure Works"
Url="https://bi.syncfusion.com/olap/msmdpump.dll">
<PivotViewAuthentication UserName="YourUsername" Password="YourPassword"></PivotViewAuthentication>
<!-- Other settings... -->
</PivotViewDataSourceSettings>If authentication is not provided in code, the browser displays a default login popup.
---
Roles
Assign SSAS roles to control data access:
<PivotViewDataSourceSettings TValue="ExpandoObject"
ProviderType="ProviderType.SSAS"
Catalog="Adventure Works DW 2008 SE"
Cube="Adventure Works"
Url="https://bi.syncfusion.com/olap/msmdpump.dll"
Roles="Role1,Role2">
<PivotViewAuthentication UserName="YourUsername" Password="YourPassword"></PivotViewAuthentication>
<!-- Other settings... -->
</PivotViewDataSourceSettings>Multiple Roles: Specify as comma-separated string: "Role1,Role2,Role3"
Roles control which cube data users can access based on SSAS security configuration.
---
Field List with OLAP
Enable the field list to allow runtime OLAP cube exploration:
<SfPivotView TValue="ProductDetails" ShowFieldList="true" Width="800" Height="350">
<PivotViewDataSourceSettings TValue="ProductDetails"
ProviderType="ProviderType.SSAS"
Catalog="Adventure Works DW 2008 SE"
Cube="Adventure Works"
Url="https://bi.syncfusion.com/olap/msmdpump.dll">
<!-- Axes configuration... -->
</PivotViewDataSourceSettings>
</SfPivotView>The field list displays:
- Dimensions with their hierarchies
- Measures
- Named sets
- Calculated members
- Display folders (organizational containers)
Users can drag cube elements between axes and apply filters/sorting.
---
Grouping Bar with OLAP
Enable the grouping bar for quick axis management:
<SfPivotView TValue="ProductDetails" ShowGroupingBar="true" Width="800" Height="350">
<PivotViewDataSourceSettings TValue="ProductDetails"
ProviderType="ProviderType.SSAS"
Catalog="Adventure Works DW 2008 SE"
Cube="Adventure Works"
Url="https://bi.syncfusion.com/olap/msmdpump.dll">
<!-- Axes configuration... -->
</PivotViewDataSourceSettings>
</SfPivotView>Users can drag cube elements between row, column, value, and filter axes directly.
---
Filter Axis
The filter axis acts as a master filter controlling data displayed across all other axes:
<PivotViewFilters>
<PivotViewFilter Name="[Date].[Fiscal]" Caption="Date Fiscal"></PivotViewFilter>
</PivotViewFilters>Use Filter Axis For:
- Dimensions that should filter the entire table
- Hierarchies that don't need to be displayed as rows/columns
- Calculated members used for filtering
Users can modify filter selections through the field list or grouping bar at runtime.
---
Virtual Scrolling with OLAP
Enable virtual scrolling for large OLAP datasets:
<SfPivotView TValue="ProductDetails"
Width="800"
Height="350"
EnableVirtualization="true"
ShowGroupingBar="true">
<PivotViewDataSourceSettings TValue="ProductDetails"
ProviderType="ProviderType.SSAS"
Catalog="Adventure Works DW 2008 SE"
Cube="Adventure Works"
Url="https://bi.syncfusion.com/olap/msmdpump.dll">
<PivotViewColumns>
<PivotViewColumn Name="[Product].[Product Categories]"></PivotViewColumn>
<PivotViewColumn Name="[Measures]"></PivotViewColumn>
</PivotViewColumns>
<PivotViewRows>
<PivotViewRow Name="[Customer].[Customer]" Caption="Customer"></PivotViewRow>
</PivotViewRows>
<PivotViewValues>
<PivotViewValue Name="[Measures].[Customer Count]"></PivotViewValue>
<PivotViewValue Name="[Measures].[Internet Sales Amount]"></PivotViewValue>
</PivotViewValues>
</PivotViewDataSourceSettings>
<PivotViewGridSettings ColumnWidth="160"></PivotViewGridSettings>
</SfPivotView>Virtual Scrolling Limitations with OLAP
1. Column Width: Must be specified in pixels (not percentage) in PivotViewGridSettings 2. Totals Display: Subtotals and grand totals appear only when measures are at the end of rows or columns 3. Column Resizing: Affects scrolling calculations 4. Performance: Large width/height values increase data loaded per page
---
OLAP Cube Elements Reference
Field List Node Types
The OLAP field list displays different icons for each element type:
| Icon Type | Element | Description | Draggable? |
|---|---|---|---|
| 📁 Folder | Display Folder | Organizational container | No |
| 📊 Chart | Measure | Numeric value for analysis | No |
| 🧊 Cube | Dimension | Categorical grouping | No |
| 📐 Hierarchy | User-Defined Hierarchy | Multi-level structure | Yes |
| 🌳 Tree | Attribute Hierarchy | Single-level hierarchy | Yes |
| ➊➋➌ Numbers | Level | Stage within hierarchy | Yes |
| 🔢 Set | Named Set | Predefined member group | Yes |
Hierarchies
User-Defined Hierarchy:
- Contains 2+ levels
- Example: Date → Year → Quarter → Month
- Allows drill-down navigation
Attribute Hierarchy:
- Contains single level
- Each dimension field creates one
- Example: Country (single level)
Measures
Measures are numeric values from the cube's fact table. Always displayed under the "Measures" dimension in the field list.
Adding to Values Axis:
<PivotViewValues>
<PivotViewValue Name="[Measures].[Internet Sales Amount]" Caption="Sales"></PivotViewValue>
</PivotViewValues>Applying Formatting:
<PivotViewFormatSettings>
<PivotViewFormatSetting Name="[Measures].[Internet Sales Amount]" Format="C0"></PivotViewFormatSetting>
</PivotViewFormatSettings>Dimensions
Dimensions organize data into categories. Each dimension can contain:
- Multiple hierarchies (user-defined and attribute)
- Levels within hierarchies
- Members and child members
- Named sets
- Calculated members
Levels
Levels represent stages within a hierarchy:
Customer Geography Hierarchy:
Level 1: Country
Level 2: State
Level 3: CityEach level can be added independently to axes for specific granularity.
---
Common Patterns
Pattern 1: Basic OLAP Connection
<SfPivotView TValue="ProductDetails">
<PivotViewDataSourceSettings TValue="ProductDetails"
ProviderType="ProviderType.SSAS"
Catalog="Your Catalog"
Cube="Your Cube"
Url="https://your-server/olap/msmdpump.dll">
</PivotViewDataSourceSettings>
</SfPivotView>Pattern 2: OLAP with Field List and Grouping Bar
<SfPivotView TValue="ProductDetails"
ShowFieldList="true"
ShowGroupingBar="true">
<PivotViewDataSourceSettings TValue="ProductDetails"
ProviderType="ProviderType.SSAS"
Catalog="Adventure Works DW 2008 SE"
Cube="Adventure Works"
Url="https://bi.syncfusion.com/olap/msmdpump.dll">
</PivotViewDataSourceSettings>
</SfPivotView>Pattern 3: OLAP with Authentication and Roles
<PivotViewDataSourceSettings TValue="ExpandoObject"
ProviderType="ProviderType.SSAS"
Roles="AnalystRole,ViewerRole">
<PivotViewAuthentication UserName="analyst1" Password="SecurePass123"></PivotViewAuthentication>
</PivotViewDataSourceSettings>Pattern 4: OLAP with Calculated Fields
<SfPivotView TValue="ProductDetails"
ShowFieldList="true"
AllowCalculatedField="true">
<PivotViewDataSourceSettings TValue="ProductDetails"
ProviderType="ProviderType.SSAS"
Catalog="Adventure Works DW 2008 SE"
Cube="Adventure Works"
Url="https://bi.syncfusion.com/olap/msmdpump.dll">
<PivotViewCalculatedFieldSettings>
<PivotViewCalculatedFieldSetting
Name="DiscountedAmount"
Formula="[Measures].[Sales Amount] * 0.9"
FormatString="Currency">
</PivotViewCalculatedFieldSetting>
</PivotViewCalculatedFieldSettings>
</PivotViewDataSourceSettings>
</SfPivotView>---
Troubleshooting
Empty Pivot Table
- Cause: Incorrect cube element names
- Solution: Verify exact names from SSAS using SQL Server Management Studio or field list
Authentication Popup
- Cause: Missing authentication in code
- Solution: Add
PivotViewAuthenticationwith credentials
Missing Totals with Virtual Scrolling
- Cause: Measures not at end of rows/columns
- Solution: Place
[Measures]as last item in row or column axis
Calculated Field Not Showing
- Cause:
IsCalculatedFieldnot set or wrong axis - Solution: Set
IsCalculatedField="true"and ensure calculated measures are in values axis
Role Access Denied
- Cause: SSAS role doesn't grant access to cube
- Solution: Verify role permissions in SSAS or use different role
---
Key Properties Summary
| Property | Location | Purpose |
|---|---|---|
ProviderType | DataSourceSettings | Set to ProviderType.SSAS for OLAP |
Url | DataSourceSettings | OLAP service endpoint (msmdpump.dll) |
Catalog | DataSourceSettings | Database/catalog name |
Cube | DataSourceSettings | OLAP cube name |
Roles | DataSourceSettings | SSAS role names (comma-separated) |
LocaleIdentifier | DataSourceSettings | Locale ID for formatting |
UserName | Authentication | Login username |
Password | Authentication | Login password |
IsNamedSet | Column/Row | Indicates named set element |
IsCalculatedField | Column/Row/Value | Indicates calculated field |
HierarchyUniqueName | CalculatedFieldSetting | Parent hierarchy for calculated dimension |
FormatString | CalculatedFieldSetting | Display format for calculated result |
PDF Export — Syncfusion Blazor Pivot Table
PDF export allows you to generate high-quality PDF documents from the pivot table with customizable page orientation, themes, and formatting.
PDF Export
Enable with AllowPdfExport="true" and call ExportToPdfAsync():
@using Syncfusion.Blazor.PivotView
@using Syncfusion.Blazor.Buttons
<SfButton OnClick="OnPdfExport" Content="Export to PDF"></SfButton>
<SfPivotView TValue="ProductDetails" @ref="pivot" AllowPdfExport="true">
<PivotViewDataSourceSettings DataSource="@data">
...
</PivotViewDataSourceSettings>
</SfPivotView>
@code {
SfPivotView<ProductDetails> pivot;
public List<ProductDetails> data { get; set; }
protected override void OnInitialized() => data = ProductDetails.GetProductData().ToList();
public void OnPdfExport() => pivot.ExportToPdfAsync();
}PDF Export with Customization
Page Orientation and Theme
@code {
public async Task OnPdfExport()
{
var exportProperties = new PdfExportProperties
{
FileName = "SalesReport.pdf",
PageOrientation = PageOrientation.Landscape,
Theme = new PdfTheme
{
Header = new PdfThemeStyle { Bold = true, FontSize = 14 },
Record = new PdfThemeStyle { FontSize = 10 }
}
};
await pivot.ExportToPdfAsync(exportProperties);
}
}Export Chart with Table
When both the pivot grid and pivot chart are visible, export them together:
<SfPivotView TValue="ProductDetails" @ref="pivot"
AllowPdfExport="true" AllowExcelExport="true">
<PivotViewDisplayOption View="View.Both" Primary="Primary.Table">
</PivotViewDisplayOption>
...
</SfPivotView>
@code {
// Export both grid and chart to PDF on the same page
public void ExportAll() => pivot.ExportToPdfAsync();
}Export as Memory Stream
Pass true to get a MemoryStream instead of downloading — useful for server-side file generation or email attachments:
@code {
public async Task ExportToStream()
{
// Returns MemoryStream — save to disk, email, or upload to storage
MemoryStream stream = await pivot.ExportToPdfAsync(true) as MemoryStream;
// e.g., save to file:
await File.WriteAllBytesAsync("output.pdf", stream.ToArray());
}
}