-
Data Grid
- Overview
-
Data Binding
-
Paging and Scrolling
-
Editing
-
Grouping
-
Filtering and Sorting
- Focused Row
-
Row Drag & Drop
-
Selection
-
Columns
- State Persistence
-
Appearance
-
Templates
-
Data Summaries
-
Master-Detail
-
Export to PDF
-
Export to Excel
-
Adaptability
- Keyboard Navigation
-
Pivot Grid
- Overview
-
Data Binding
-
Field Chooser
-
Features
-
Export to Excel
-
Tree List
- Overview
-
Data Binding
- Sorting
- Paging
-
Editing
- Node Drag & Drop
- Focused Row
-
Selection
-
Filtering
-
Column Customization
- State Persistence
- Adaptability
- Keyboard Navigation
-
Scheduler
- Overview
-
Data Binding
-
Views
-
Features
- Virtual Scrolling
-
Grouping
-
Customization
- Adaptability
-
Html Editor
-
Chat
-
Diagram
- Overview
-
Data Binding
-
Featured Shapes
-
Custom Shapes
-
Document Capabilities
-
User Interaction
- UI Customization
- Adaptability
-
Charts
- Overview
-
Data Binding
-
Area Charts
-
Bar Charts
- Bullet Charts
-
Doughnut Charts
-
Financial Charts
-
Line Charts
-
Pie Charts
-
Point Charts
-
Polar and Radar Charts
-
Range Charts
-
Sparkline Charts
-
Tree Map
-
Funnel and Pyramid Charts
- Sankey Chart
-
Combinations
-
More Features
-
Export
-
Selection
-
Tooltips
-
Zooming
-
-
Gantt
- Overview
-
Data
-
UI Customization
- Strip Lines
- Export to PDF
- Sorting
-
Filtering
-
Gauges
- Overview
-
Data Binding
-
Bar Gauge
-
Circular Gauge
-
Linear Gauge
-
Navigation
- Overview
- Accordion
-
Menu
- Multi View
-
Drawer
-
Tab Panel
-
Tabs
-
Toolbar
- Pagination
-
Tree View
- Right-to-Left Support
-
Layout
-
Tile View
- Splitter
-
Gallery
- Scroll View
- Box
- Responsive Box
- Resizable
-
-
Editors
- Overview
- Autocomplete
-
Calendar
- Check Box
- Color Box
-
Date Box
-
Date Range Box
-
Drop Down Box
-
Number Box
-
Select Box
- Switch
-
Tag Box
- Text Area
- Text Box
- Validation
- Custom Text Editor Buttons
- Right-to-Left Support
- Editor Appearance Variants
-
Forms and Multi-Purpose
- Overview
- Button Group
- Field Set
-
Filter Builder
-
Form
- Radio Group
-
Range Selector
- Numeric Scale (Lightweight)
- Numeric Scale
- Date-Time Scale (Lightweight)
- Date-Time Scale
- Logarithmic Scale
- Discrete scale
- Custom Formatting
- Use Range Selection for Calculation
- Use Range Selection for Filtering
- Image on Background
- Chart on Background
- Customized Chart on Background
- Chart on Background with Series Template
- Range Slider
- Slider
-
Sortable
-
File Management
-
File Manager
- Overview
-
File System Types
-
Customization
-
File Uploader
-
-
Actions and Lists
- Overview
-
Action Sheet
-
Button
- Floating Action Button
- Drop Down Button
-
Context Menu
-
List
-
Lookup
-
Maps
- Overview
-
Map
-
Vector Map
-
Dialogs and Notifications
-
Localization
React Pivot Grid - Summary Display Modes
Summary display modes are post-processing functions that allow you to perform additional calculations on each summary value and take into account neighboring summary values. You can use summary display modes to present pivot data from different angles.
If you have technical questions, please create a support ticket in the DevExpress Support Center.
import React from 'react';
import PivotGrid, {
FieldChooser,
FieldPanel,
} from 'devextreme-react/pivot-grid';
import PivotGridDataSource from 'devextreme/ui/pivot_grid/data_source';
import sales from './data.ts';
const onContextMenuPreparing = (e) => {
if (e.field && e.field.dataField === 'amount') {
summaryDisplayModes.forEach((mode) => {
e.items.push({
text: mode.text,
selected: e.field.summaryDisplayMode === mode.value,
onItemClick: () => {
let format: string;
const caption = mode.value === 'none' ? 'Total Sales' : 'Relative Sales';
if (mode.value === 'none' || mode.value === 'absoluteVariation') {
format = 'currency';
}
dataSource.field(e.field.index, {
summaryDisplayMode: mode.value,
format,
caption,
});
dataSource.load();
},
});
});
}
};
const summaryDisplayModes = [
{ text: 'None', value: 'none' },
{ text: 'Absolute Variation', value: 'absoluteVariation' },
{ text: 'Percent Variation', value: 'percentVariation' },
{ text: 'Percent of Column Total', value: 'percentOfColumnTotal' },
{ text: 'Percent of Row Total', value: 'percentOfRowTotal' },
{ text: 'Percent of Column Grand Total', value: 'percentOfColumnGrandTotal' },
{ text: 'Percent of Row Grand Total', value: 'percentOfRowGrandTotal' },
{ text: 'Percent of Grand Total', value: 'percentOfGrandTotal' },
];
const dataSource = new PivotGridDataSource({
fields: [
{
caption: 'Region',
width: 120,
dataField: 'region',
area: 'row',
},
{
caption: 'City',
dataField: 'city',
width: 150,
area: 'row',
},
{
dataField: 'date',
dataType: 'date',
area: 'column',
},
{
groupName: 'date',
groupInterval: 'year',
expanded: true,
},
{
caption: 'Relative Sales',
dataField: 'amount',
dataType: 'number',
summaryType: 'sum',
area: 'data',
summaryDisplayMode: 'percentOfColumnGrandTotal',
},
],
store: sales,
});
const App = () =>
(
<React.Fragment>
<div className="desc-container">
Right-click (or touch and hold) the "Relative Sales" field
and select an item from the appeared context menu to change the
<b> "summaryDisplayMode"</b> option.
</div>
<PivotGrid
id="sales"
dataSource={dataSource}
allowSortingBySummary={true}
allowSorting={true}
allowExpandAll={true}
showBorders={true}
onContextMenuPreparing={onContextMenuPreparing}
>
<FieldPanel showFilterFields={false} allowFieldDragging={false} visible={true} />
<FieldChooser enabled={false} />
</PivotGrid>
</React.Fragment>
);
export default App;
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
Apply a Summary Display Mode
DevExtreme PivotGrid supports predefined summary display modes decribed below. To apply one of them, set the summaryDisplayMode property.
-
"absoluteVariation"
Calculates the absolute difference between the current and previous value in a row. Starts from the second value in the row because the first does not have a previous value. -
"percentVariation"
Same as the absolute variation, but the difference is calculated as a percentage. -
"percentOfColumnTotal"
Calculates the current value as a percentage in one of the column's intermediate totals or the column's grand total when there are no expanded rows. -
"percentOfRowTotal"
Calculates the current value as a percentage in one of the row's intermediate totals or the row's grand total when there are no expanded columns. -
"percentOfColumnGrandTotal"
Calculates the current value as a percentage in the column's grand total. -
"percentOfRowGrandTotal"
Calculates the current value as a percentage in the row's grand total. -
"percentOfGrandTotal"
Calculates the current value as a percentage in the grand total of the entire pivot grid.
If the predefined modes do not suit your needs, you can implement a custom post-processing function—calculateSummaryValue. Note that the PivotGrid ignores the summaryDisplayMode property if the calculateSummaryValue function is defined.
Change the Summary Display Mode at Runtime
In this demo, you can switch between predefined summary display modes at runtime. Right-click or long-tap the Relative Sales field in the field panel and select a mode from the invoked context menu.
To implement this functionality in your application, use the onContextMenuPreparing event handler. Within this handler, you should detect the right-clicked field. If it is a target field, change its summaryDisplayMode and optionally other properties, such as caption or format.