The classic (tabular) form is a React pivot table view that displays data in an Excel-like layout. With the classic pivot table view, you can show sublevels in separate rows or columns next to one another.
Play with the demo on a larger screen: save this link for later or watch the video review now.
import { useRef } from "react";
import * as FlexmonsterReact from "react-flexmonster";
import "flexmonster/flexmonster.css";
function PivotTableDemo() {
const pivotRef = useRef(null);
const report = {
dataSource: {
type: "csv",
filename: "https://cdn.flexmonster.com/data/data.csv"
},
options: {
grid: {
type: "classic"
}
},
slice: {
rows: [
{
uniqueName: "Country"
},
{
uniqueName: "Business Type"
}
],
columns: [
{
uniqueName: "Color"
},
{
uniqueName: "[Measures]"
}
],
measures: [
{
uniqueName: "Price",
format: "currency"
}
],
expandAll: true
},
formats: [
{
name: "",
thousandsSeparator: ",",
decimalSeparator: ".",
decimalPlaces: 2
},
{
name: "currency",
currencySymbol: "$"
}
]
};
const changeLayout = (layoutType) => {
pivotRef.current.flexmonster.setOptions({
grid: {
type: layoutType
}
});
pivotRef.current.flexmonster.refresh();
};
const setRepeatLabels = (enabled) => {
pivotRef.current.flexmonster.setOptions({
grid: {
repeatAllLabels: enabled
}
});
pivotRef.current.flexmonster.refresh();
};
return (
<>
<button onClick={() => changeLayout("compact")}>Use compact form</button>
<button onClick={() => changeLayout("classic")}>Use classic form</button>
<button onClick={() => setRepeatLabels(true)}>Repeat labels on</button>
<button onClick={() => setRepeatLabels(false)}>Repeat labels off</button>
<FlexmonsterReact.Pivot
ref={pivotRef}
report={report}
/>
</>
);
}
export default PivotTableDemo;
By default, grand totals are displayed at the end of each row, and subtotals are placed at the bottom in a separate row.
All the React pivot table functionality works similarly to what you're used to in Excel. You can drag and drop, expand, collapse, drill down and up the hierarchies, sort and drill through values, and more.
In case multilevel hierarchies from your report include a lot of sublevels, it is better to switch to the compact form, which shows them more neatly and saves space on the page.
Can't find your answer here?
Visit the FAQ page
Flexmonster Pivot Table & Charts is a JavaScript pivot table component for adding interactive reporting and data analysis to web applications. Users can summarize, filter, sort, and explore data in pivot tables and charts, drill into results, and export reports.
Flexmonster works in plain JavaScript and TypeScript projects. It also integrates with React, Next.js, Angular, Vue, Blazor, and other technologies. See all integration options.
Flexmonster supports JSON and CSV files, SQL databases, MongoDB, Elasticsearch, and Microsoft Analysis Services (SSAS). You can also connect other data sources through your own backend. See supported data sources.
Flexmonster offers licenses for internal corporate use, SaaS products, and OEM distribution. Pricing varies by license and plan. SaaS projects can also use the free SaaS Entry license during development. Learn more on the pricing page.
Yes. Flexmonster offers a 30-day free trial that lets you evaluate all its features. No credit card is required. The trial version has a watermark.
To get started with Flexmonster, follow our integration guide.