Implementing PivotView in React
The Syncfusion React PivotView component enables powerful data analysis and reporting capabilities. It allows users to organize, analyze, and summarize multidimensional data through interactive pivot tables with features like grouping, filtering, aggregation, drill-down analysis, and export functionality.
⚠️ 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:
- Use Local Data: Prefer local, in-memory data sources for maximum security
- Validate Remote Sources: Only connect to authenticated and authorized API endpoints under your control
- Sanitize User Input: Never allow users to specify arbitrary URLs or data sources
- Implement Authentication: Always use authentication headers and secure API endpoints
- Content Validation: Validate and sanitize all data received from external sources before binding
- Use HTTPS: Always use HTTPS for remote data connections
- 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 environment variables 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
Use this skill when you need to:
- Create interactive pivot tables for data analysis
- Set up data aggregation and summarization
- Build dynamic reporting dashboards
- Configure row/column grouping with hierarchies
- Implement data filtering and sorting
- Add drill-down/drill-through capabilities
- Export reports to Excel or PDF
- Optimize performance for large datasets
- Style and format pivot table display
- Persist pivot table state across sessions
Navigation Guide
Setup
📄 Read: references/getting-started.md
- Installation, package setup, basic component creation, CSS imports, NextJS integration
📄 Read (optional): references/nextjs-integration.md
- Next.js App Router and Pages Router setup, dynamic imports, SSR considerations, API routes, deployment
Data Management
📄 Read: references/data-binding.md
- JSON data binding, CSV data binding, remote data binding, field mapping, DataManager setup
📄 Read: references/connecting-to-databases.md
- Database connections, Web API setup, SQL Server, MySQL, PostgreSQL, MongoDB, Oracle, Elasticsearch, Snowflake
📄 Read: references/connecting-to-data-source.md
- OLAP connections, server-side engine configuration, real-time data updates
Visualization & Interaction
📄 Read: references/pivot-chart.md
- Integrating pivot charts, chart types, visualization options, chart customization
📄 Read: references/classic-layout.md
- Classic layout configuration, layout switching, UI control options
📄 Read: references/drill.md
- Drill-down and drill-through functionality, editing, navigation controls, event handling
Data Organization & Display
📄 Read: references/field-list.md
- In-built field list (popup), stand-alone field list (fixed), field list modes, UI interactions, configuration options
📄 Read: references/grouping-bar.md
- Grouping bar configuration, drag-and-drop operations, filter/sort/remove icons, fields panel, value type icon, exclusion options
📄 Read: references/data-shaping.md
- Aggregation functions, calculated fields (defining and editing), summary customization options
📄 Read: references/aggregation.md
- 24+ aggregation types (Sum, Average, Count, etc.), advanced aggregations, base field configuration, runtime modification
📄 Read: references/calculated-field.md
- Interactive calculated field dialog, formula syntax and operators, code-based methods, format settings
📄 Read: references/grouping.md
- Data grouping feature, number grouping with ranges, date grouping with hierarchies, programmatic configuration, ungrouping
📄 Read: references/data-formatting.md
- Number formatting, conditional formatting, cell styling, tooltip customization
📄 Read: references/grid-customization.md
- Cell templates, row heights, column widths, text alignment, column resizing and reordering, dimension configuration
📄 Read: references/row-and-column.md
- Cell template customization, dimension configuration, row height, column width, resizing, reordering, text alignment
📄 Read: references/filtering-and-sorting.md
- Member filtering, label filtering, value filtering, sorting operations, filter customization
📄 Read separately if needed:
- references/member-filtering.md - Select/exclude specific members, interactive filter dialogs, append current selection to existing filters
- references/label-filtering.md - Filter by text patterns, date ranges, numeric ranges
- references/value-filtering.md - Filter by aggregated values, Top/Bottom N members (client-side), clearing value filter
- references/value-sorting.md - Sort by measure values, ranking analysis, multi-level sorting
📄 Read: references/show-hide-totals.md
- Grand totals display, group totals configuration, subtotal calculation options
📄 Read: references/state-persistence.md
- Save and load pivot table state, persistence configuration, state management patterns
📄 Read: references/toolbar.md
- Toolbar controls, button customization, toolbar events and actions
📄 Read: references/tooltip.md
- Tooltip configuration, custom tooltip templates, tooltip formatting
📄 Read: references/hyperlink.md
- Hyperlink configuration, cell linking, navigation setup, link customization
Navigation & Analysis
📄 Read: references/drill.md
- Drill-down and drill-through functionality, hierarchical data exploration, editing capabilities
📄 Read separately if needed:
- references/drill-down.md - Drill-down specific features
- references/drill-through.md - Drill-through and raw data exploration
Export & Output
📄 Read: references/export.md
- Excel export, PDF export, export configurations, custom export handlers
📄 Read separately if needed:
- references/excel-export.md - Excel export details
- references/pdf-export.md - PDF export details
📄 Read: references/print.md
- Pivot table printing, chart printing, print configurations, browser compatibility
Advanced & Performance
📄 Read: references/defer-update.md
- Deferred layout updates, Apply button, batch field operations, performance optimization for large datasets
📄 Read: references/performance.md
- Virtual scrolling, paging configuration, performance best practices, data compression
📄 Read separately if needed:
- references/virtual-scrolling.md - Efficient rendering of 100K+ rows, virtual scroll settings, responsive optimization
Quick Start
Install the Tailwind 3 theme package. Each component in this theme package includes an index.css file that automatically loads all required dependency styles.
npm install @syncfusion/ej2-tailwind3-theme --save
By default, Vite projects include an index.css file with default styles. These default styles may conflict with Syncfusion component styles. Clear all content from the index.css file to prevent style conflicts.
The required styles for the Pivot Table component are imported in the src/App.css file:
/* App.css */
@import '../node_modules/@syncfusion/ej2-tailwind3-theme/styles/pivotview/index.css';
import { PivotViewComponent, Inject, GroupingBar, FieldList, IDataSet } from '@syncfusion/ej2-react-pivotview';
import './App.css';
const pivotData: IDataSet[] = [
{ Country: 'USA', Product: 'Laptops', Sales: 5000, Year: 2020 },
{ Country: 'USA', Product: 'Mobiles', Sales: 3000, Year: 2020 },
{ Country: 'Canada', Product: 'Laptops', Sales: 2500, Year: 2020 },
{ Country: 'Canada', Product: 'Mobiles', Sales: 1500, Year: 2020 }
];
function cellTemplate(props: any): JSX.Element {
return (
<span style={{ fontWeight: 'bold', color: '#333' }}>
{props.cellInfo?.value}
</span>
);
}
function App() {
const dataSourceSettings: DataSourceSettingsModel = {
dataSource: pivotData as IDataSet[],
rows: [{ name: 'Country' }],
columns: [{ name: 'Product' }],
values: [{ name: 'Sales', caption: 'Total Sales' }],
showGrandTotals: true
};
return (
<PivotViewComponent
id="pivotview"
dataSourceSettings={dataSourceSettings}
cellTemplate={cellTemplate}
showGroupingBar={true}
showFieldList={true}
height={350}
>
<Inject services={[GroupingBar, FieldList]} />
</PivotViewComponent>
);
}
export default App;
Common Patterns
Pattern 1: Basic Pivot Table with Row and Column Fields
const dataSourceSettings: DataSourceSettingsModel = {
dataSource: data as IDataSet[],
rows: [{ name: 'Country' }, { name: 'Region' }],
columns: [{ name: 'Year' }, { name: 'Quarter' }],
values: [{ name: 'Sales', caption: 'Total Sales' }]
};
Pattern 2: Adding Filters and Aggregation
const dataSourceSettings: DataSourceSettingsModel = {
dataSource: data as IDataSet[],
rows: [{ name: 'Country' }],
columns: [{ name: 'Product' }],
values: [
{ name: 'Sales', type: 'Sum' },
{ name: 'Quantity', type: 'Avg' }
],
filters: [{ name: 'Year' }]
};
Pattern 3: Calculated Fields
import { PivotViewComponent, Inject, CalculatedField, FieldList } from '@syncfusion/ej2-react-pivotview';
import { DataSourceSettingsModel } from '@syncfusion/ej2-pivotview/src/model/datasourcesettings-model';
const dataSourceSettings: DataSourceSettingsModel = {
dataSource: data as IDataSet[],
rows: [{ name: 'Country' }],
columns: [{ name: 'Product' }],
values: [
{ name: 'Sold', caption: 'Units Sold' },
{ name: 'Amount', caption: 'Amount' },
{ name: 'Total', caption: 'Total', type: 'CalculatedField' } // ← Must add to values
],
calculatedFieldSettings: [
{
name: 'Total',
formula: '"Sum(Amount)"+"Sum(Sold)"' // ← Formula with aggregation functions
}
]
};
Pattern 4: Cell Template with Conditional Formatting
function cellTemplate(props: any): JSX.Element {
const value = props.cellInfo?.value;
const isTotal = props.cellInfo?.isGrandTotal || props.cellInfo?.isDeserialized;
const getStyle = () => {
const numValue = parseFloat(value);
if (numValue > 4000) return { color: '#4CAF50', fontWeight: 'bold' }; // Green for high values
if (numValue < 1000) return { color: '#f44336', fontWeight: 'bold' }; // Red for low values
return { color: '#333' };
};
return (
<span style={getStyle()}>
{isTotal ? <strong>{value}</strong> : value}
</span>
);
}
const dataSourceSettings: DataSourceSettingsModel = {
dataSource: data as IDataSet[],
rows: [{ name: 'Country' }],
columns: [{ name: 'Product' }],
values: [{ name: 'Sales' }]
};
Key Props & Configuration
| Property |
Type |
Description |
dataSourceSettings |
object |
Configures data source, fields, rows, columns, values, filters, aggregations, calculated fields, and formatting |
cellTemplate |
function |
Custom cell rendering function that returns JSX.Element for value cells |
gridSettings |
GridSettings |
Configures row height, column width, text wrapping, resizing, reordering |
height |
string/number |
Component height in pixels or percentage |
width |
string/number |
Component width in pixels or percentage |
showGroupingBar |
boolean |
Shows/hides the grouping bar for drag-and-drop field management |
showFieldList |
boolean |
Shows/hides the field list panel (built-in or side panel) |
allowCalculatedField |
boolean |
Enables calculated field creation and editing via Field List dialog |
allowExcelExport |
boolean |
Enables Excel export functionality |
allowPdfExport |
boolean |
Enables PDF export functionality |
allowMemberFilter |
boolean |
Enables member filtering in Field List (select/deselect members) |
allowLabelFilter |
boolean |
Enables label filtering (filter by text/label values) |
allowValueFilter |
boolean |
Enables value filtering (filter by aggregated values) |
allowDrillThrough |
boolean |
Enables drill-through functionality to view pivot data |
allowConditionalFormatting |
boolean |
Enables conditional formatting for cells based on values |
allowDeferLayoutUpdate |
boolean |
Batches field operations in Field List, apply only on "Apply" click |
enableVirtualization |
boolean |
Enables virtual scrolling for large datasets |
enablePaging |
boolean |
Enables paging for row/column distribution |
showToolbar |
boolean |
Shows/hides the toolbar with preset actions |
pageSettings |
PageSettings |
Configures row and column page sizes for paging |
GridSettings Configuration
rowHeight: Specifies row height in pixels
columnWidth: Sets default column width
allowResizing: Enables column/row resizing
allowReordering: Allows drag-and-drop field reordering
allowTextWrap: Enables text wrapping in cells
columnRender: Event handler for column customization (e.g., text alignment)
Related Skills
- Syncfusion React Grid - For general data grid functionality
- React Data Binding - For data source management patterns
1---
2name: syncfusion-react-pivot-table
3description: Use this skill when users ask how to build or customize Syncfusion PivotView pivot tables in React. Trigger for React pivot grid/OLAP, aggregation, data binding (JSON/remote), drill-down/drill-through, grouping, filtering, conditional formatting, exports (Excel/PDF/CSV), or pivot charts. React-only, not Angular/Vue/Blazor.
4metadata:
5 author: "Syncfusion Inc"
6 version: "34.1.29"
7 category: "Grids"
8---
9
10# Implementing PivotView in React
11
12The Syncfusion React PivotView component enables powerful data analysis and reporting capabilities. It allows users to organize, analyze, and summarize multidimensional data through interactive pivot tables with features like grouping, filtering, aggregation, drill-down analysis, and export functionality.
13
14> ⚠️ **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.
15
16## ⚠️ Security Warning: Data Source Validation
17
18**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.
19
20### Security Best Practices:
21
221. **Use Local Data**: Prefer local, in-memory data sources for maximum security
232. **Validate Remote Sources**: Only connect to authenticated and authorized API endpoints under your control
243. **Sanitize User Input**: Never allow users to specify arbitrary URLs or data sources
254. **Implement Authentication**: Always use authentication headers and secure API endpoints
265. **Content Validation**: Validate and sanitize all data received from external sources before binding
276. **Use HTTPS**: Always use HTTPS for remote data connections
287. **Rate Limiting**: Implement rate limiting on API endpoints to prevent abuse
29
30### Security Risks:
31
32- **Indirect Prompt Injection**: Untrusted third-party data can contain malicious content that manipulates AI agent behavior
33- **Data Exfiltration**: Malicious data sources could attempt to extract sensitive information
34- **Code Injection**: Untrusted data may contain scripts or harmful content
35
36### Recommended Approach:
37
38✅ **DO**: Use controlled, authenticated backend APIs
39✅ **DO**: Implement server-side data validation
40✅ **DO**: Use environment variables for API endpoints
41✅ **DO**: Whitelist allowed data sources
42
43❌ **DON'T**: Accept user-provided URLs
44❌ **DON'T**: Bind to public, untrusted endpoints
45❌ **DON'T**: Skip data validation and sanitization
46❌ **DON'T**: Use HTTP for sensitive data
47
48## When to Use This Skill
49
50Use this skill when you need to:
51- Create interactive pivot tables for data analysis
52- Set up data aggregation and summarization
53- Build dynamic reporting dashboards
54- Configure row/column grouping with hierarchies
55- Implement data filtering and sorting
56- Add drill-down/drill-through capabilities
57- Export reports to Excel or PDF
58- Optimize performance for large datasets
59- Style and format pivot table display
60- Persist pivot table state across sessions
61
62## Navigation Guide
63
64### Setup
65📄 **Read:** [references/getting-started.md](references/getting-started.md)
66- Installation, package setup, basic component creation, CSS imports, NextJS integration
67
68📄 **Read (optional):** [references/nextjs-integration.md](references/nextjs-integration.md)
69- Next.js App Router and Pages Router setup, dynamic imports, SSR considerations, API routes, deployment
70
71### Data Management
72📄 **Read:** [references/data-binding.md](references/data-binding.md)
73- JSON data binding, CSV data binding, remote data binding, field mapping, DataManager setup
74
75📄 **Read:** [references/connecting-to-databases.md](references/connecting-to-databases.md)
76- Database connections, Web API setup, SQL Server, MySQL, PostgreSQL, MongoDB, Oracle, Elasticsearch, Snowflake
77
78📄 **Read:** [references/connecting-to-data-source.md](references/connecting-to-data-source.md)
79- OLAP connections, server-side engine configuration, real-time data updates
80
81### Visualization & Interaction
82📄 **Read:** [references/pivot-chart.md](references/pivot-chart.md)
83- Integrating pivot charts, chart types, visualization options, chart customization
84
85📄 **Read:** [references/classic-layout.md](references/classic-layout.md)
86- Classic layout configuration, layout switching, UI control options
87
88📄 **Read:** [references/drill.md](references/drill.md)
89- Drill-down and drill-through functionality, editing, navigation controls, event handling
90
91### Data Organization & Display
92📄 **Read:** [references/field-list.md](references/field-list.md)
93- In-built field list (popup), stand-alone field list (fixed), field list modes, UI interactions, configuration options
94
95📄 **Read:** [references/grouping-bar.md](references/grouping-bar.md)
96- Grouping bar configuration, drag-and-drop operations, filter/sort/remove icons, fields panel, value type icon, exclusion options
97
98📄 **Read:** [references/data-shaping.md](references/data-shaping.md)
99- Aggregation functions, calculated fields (defining and editing), summary customization options
100
101📄 **Read:** [references/aggregation.md](references/aggregation.md)
102- 24+ aggregation types (Sum, Average, Count, etc.), advanced aggregations, base field configuration, runtime modification
103
104📄 **Read:** [references/calculated-field.md](references/calculated-field.md)
105- Interactive calculated field dialog, formula syntax and operators, code-based methods, format settings
106
107📄 **Read:** [references/grouping.md](references/grouping.md)
108- Data grouping feature, number grouping with ranges, date grouping with hierarchies, programmatic configuration, ungrouping
109
110📄 **Read:** [references/data-formatting.md](references/data-formatting.md)
111- Number formatting, conditional formatting, cell styling, tooltip customization
112
113📄 **Read:** [references/grid-customization.md](references/grid-customization.md)
114- Cell templates, row heights, column widths, text alignment, column resizing and reordering, dimension configuration
115
116📄 **Read:** [references/row-and-column.md](references/row-and-column.md)
117- Cell template customization, dimension configuration, row height, column width, resizing, reordering, text alignment
118
119📄 **Read:** [references/filtering-and-sorting.md](references/filtering-and-sorting.md)
120- Member filtering, label filtering, value filtering, sorting operations, filter customization
121
122📄 **Read separately if needed:**
123- [references/member-filtering.md](references/member-filtering.md) - Select/exclude specific members, interactive filter dialogs, append current selection to existing filters
124- [references/label-filtering.md](references/label-filtering.md) - Filter by text patterns, date ranges, numeric ranges
125- [references/value-filtering.md](references/value-filtering.md) - Filter by aggregated values, Top/Bottom N members (client-side), clearing value filter
126- [references/value-sorting.md](references/value-sorting.md) - Sort by measure values, ranking analysis, multi-level sorting
127
128📄 **Read:** [references/show-hide-totals.md](references/show-hide-totals.md)
129- Grand totals display, group totals configuration, subtotal calculation options
130
131📄 **Read:** [references/state-persistence.md](references/state-persistence.md)
132- Save and load pivot table state, persistence configuration, state management patterns
133
134📄 **Read:** [references/toolbar.md](references/toolbar.md)
135- Toolbar controls, button customization, toolbar events and actions
136
137📄 **Read:** [references/tooltip.md](references/tooltip.md)
138- Tooltip configuration, custom tooltip templates, tooltip formatting
139
140📄 **Read:** [references/hyperlink.md](references/hyperlink.md)
141- Hyperlink configuration, cell linking, navigation setup, link customization
142
143### Navigation & Analysis
144📄 **Read:** [references/drill.md](references/drill.md)
145- Drill-down and drill-through functionality, hierarchical data exploration, editing capabilities
146
147📄 **Read separately if needed:**
148- [references/drill-down.md](references/drill-down.md) - Drill-down specific features
149- [references/drill-through.md](references/drill-through.md) - Drill-through and raw data exploration
150
151### Export & Output
152📄 **Read:** [references/export.md](references/export.md)
153- Excel export, PDF export, export configurations, custom export handlers
154
155📄 **Read separately if needed:**
156- [references/excel-export.md](references/excel-export.md) - Excel export details
157- [references/pdf-export.md](references/pdf-export.md) - PDF export details
158
159📄 **Read:** [references/print.md](references/print.md)
160- Pivot table printing, chart printing, print configurations, browser compatibility
161
162### Advanced & Performance
163📄 **Read:** [references/defer-update.md](references/defer-update.md)
164- Deferred layout updates, Apply button, batch field operations, performance optimization for large datasets
165
166📄 **Read:** [references/performance.md](references/performance.md)
167- Virtual scrolling, paging configuration, performance best practices, data compression
168
169📄 **Read separately if needed:**
170- [references/virtual-scrolling.md](references/virtual-scrolling.md) - Efficient rendering of 100K+ rows, virtual scroll settings, responsive optimization
171
172## Quick Start
173
174Install the [Tailwind 3](https://www.npmjs.com/package/@syncfusion/ej2-tailwind3-theme) theme package. Each component in this theme package includes an `index.css` file that automatically loads all required dependency styles.
175
176```bash
177npm install @syncfusion/ej2-tailwind3-theme --save
178```
179
180By default, Vite projects include an `index.css` file with default styles. These default styles may conflict with Syncfusion component styles. Clear all content from the `index.css` file to prevent style conflicts.
181
182The required styles for the Pivot Table component are imported in the **src/App.css** file:
183
184```css
185/* App.css */
186@import '../node_modules/@syncfusion/ej2-tailwind3-theme/styles/pivotview/index.css';
187```
188
189```typescript
190import { PivotViewComponent, Inject, GroupingBar, FieldList, IDataSet } from '@syncfusion/ej2-react-pivotview';
191import './App.css';
192
193const pivotData: IDataSet[] = [
194 { Country: 'USA', Product: 'Laptops', Sales: 5000, Year: 2020 },
195 { Country: 'USA', Product: 'Mobiles', Sales: 3000, Year: 2020 },
196 { Country: 'Canada', Product: 'Laptops', Sales: 2500, Year: 2020 },
197 { Country: 'Canada', Product: 'Mobiles', Sales: 1500, Year: 2020 }
198];
199
200function cellTemplate(props: any): JSX.Element {
201 return (
202 <span style={{ fontWeight: 'bold', color: '#333' }}>
203 {props.cellInfo?.value}
204 </span>
205 );
206}
207
208function App() {
209 const dataSourceSettings: DataSourceSettingsModel = {
210 dataSource: pivotData as IDataSet[],
211 rows: [{ name: 'Country' }],
212 columns: [{ name: 'Product' }],
213 values: [{ name: 'Sales', caption: 'Total Sales' }],
214 showGrandTotals: true
215 };
216
217 return (
218 <PivotViewComponent
219 id="pivotview"
220 dataSourceSettings={dataSourceSettings}
221 cellTemplate={cellTemplate}
222 showGroupingBar={true}
223 showFieldList={true}
224 height={350}
225 >
226 <Inject services={[GroupingBar, FieldList]} />
227 </PivotViewComponent>
228 );
229}
230
231export default App;
232```
233
234## Common Patterns
235
236### Pattern 1: Basic Pivot Table with Row and Column Fields
237```typescript
238const dataSourceSettings: DataSourceSettingsModel = {
239 dataSource: data as IDataSet[],
240 rows: [{ name: 'Country' }, { name: 'Region' }],
241 columns: [{ name: 'Year' }, { name: 'Quarter' }],
242 values: [{ name: 'Sales', caption: 'Total Sales' }]
243};
244```
245
246### Pattern 2: Adding Filters and Aggregation
247```typescript
248const dataSourceSettings: DataSourceSettingsModel = {
249 dataSource: data as IDataSet[],
250 rows: [{ name: 'Country' }],
251 columns: [{ name: 'Product' }],
252 values: [
253 { name: 'Sales', type: 'Sum' },
254 { name: 'Quantity', type: 'Avg' }
255 ],
256 filters: [{ name: 'Year' }]
257};
258```
259
260### Pattern 3: Calculated Fields
261```typescript
262import { PivotViewComponent, Inject, CalculatedField, FieldList } from '@syncfusion/ej2-react-pivotview';
263import { DataSourceSettingsModel } from '@syncfusion/ej2-pivotview/src/model/datasourcesettings-model';
264
265const dataSourceSettings: DataSourceSettingsModel = {
266 dataSource: data as IDataSet[],
267 rows: [{ name: 'Country' }],
268 columns: [{ name: 'Product' }],
269 values: [
270 { name: 'Sold', caption: 'Units Sold' },
271 { name: 'Amount', caption: 'Amount' },
272 { name: 'Total', caption: 'Total', type: 'CalculatedField' } // ← Must add to values
273 ],
274 calculatedFieldSettings: [
275 {
276 name: 'Total',
277 formula: '"Sum(Amount)"+"Sum(Sold)"' // ← Formula with aggregation functions
278 }
279 ]
280};
281```
282
283### Pattern 4: Cell Template with Conditional Formatting
284```typescript
285function cellTemplate(props: any): JSX.Element {
286 const value = props.cellInfo?.value;
287 const isTotal = props.cellInfo?.isGrandTotal || props.cellInfo?.isDeserialized;
288
289 const getStyle = () => {
290 const numValue = parseFloat(value);
291 if (numValue > 4000) return { color: '#4CAF50', fontWeight: 'bold' }; // Green for high values
292 if (numValue < 1000) return { color: '#f44336', fontWeight: 'bold' }; // Red for low values
293 return { color: '#333' };
294 };
295
296 return (
297 <span style={getStyle()}>
298 {isTotal ? <strong>{value}</strong> : value}
299 </span>
300 );
301}
302
303const dataSourceSettings: DataSourceSettingsModel = {
304 dataSource: data as IDataSet[],
305 rows: [{ name: 'Country' }],
306 columns: [{ name: 'Product' }],
307 values: [{ name: 'Sales' }]
308};
309```
310
311## Key Props & Configuration
312
313| Property | Type | Description |
314|----------|------|-----------|
315| `dataSourceSettings` | object | Configures data source, fields, rows, columns, values, filters, aggregations, calculated fields, and formatting |
316| `cellTemplate` | function | Custom cell rendering function that returns JSX.Element for value cells |
317| `gridSettings` | GridSettings | Configures row height, column width, text wrapping, resizing, reordering |
318| `height` | string/number | Component height in pixels or percentage |
319| `width` | string/number | Component width in pixels or percentage |
320| `showGroupingBar` | boolean | Shows/hides the grouping bar for drag-and-drop field management |
321| `showFieldList` | boolean | Shows/hides the field list panel (built-in or side panel) |
322| `allowCalculatedField` | boolean | Enables calculated field creation and editing via Field List dialog |
323| `allowExcelExport` | boolean | Enables Excel export functionality |
324| `allowPdfExport` | boolean | Enables PDF export functionality |
325| `allowMemberFilter` | boolean | Enables member filtering in Field List (select/deselect members) |
326| `allowLabelFilter` | boolean | Enables label filtering (filter by text/label values) |
327| `allowValueFilter` | boolean | Enables value filtering (filter by aggregated values) |
328| `allowDrillThrough` | boolean | Enables drill-through functionality to view pivot data |
329| `allowConditionalFormatting` | boolean | Enables conditional formatting for cells based on values |
330| `allowDeferLayoutUpdate` | boolean | Batches field operations in Field List, apply only on "Apply" click |
331| `enableVirtualization` | boolean | Enables virtual scrolling for large datasets |
332| `enablePaging` | boolean | Enables paging for row/column distribution |
333| `showToolbar` | boolean | Shows/hides the toolbar with preset actions |
334| `pageSettings` | PageSettings | Configures row and column page sizes for paging |
335
336### GridSettings Configuration
337- `rowHeight`: Specifies row height in pixels
338- `columnWidth`: Sets default column width
339- `allowResizing`: Enables column/row resizing
340- `allowReordering`: Allows drag-and-drop field reordering
341- `allowTextWrap`: Enables text wrapping in cells
342- `columnRender`: Event handler for column customization (e.g., text alignment)
343
344## Related Skills
345- Syncfusion React Grid - For general data grid functionality
346- React Data Binding - For data source management patterns