|
1 | 1 | # Group Row and Column Headers in React Pivot Table |
2 | 2 |
|
3 | | -A quick-start project that shows how to group row and column field items in React Pivot Table of Syncfusion based on date, time, number, and string types. |
| 3 | +This sample demonstrates how to **group row and column field items in a React Pivot Table** using [Syncfusion's PivotView component](https://ej2.syncfusion.com/react/documentation/pivotview/grouping/). It covers grouping based on **date, time, number, and string types**, making it easier to analyze and summarize data. |
4 | 4 |
|
5 | | -Documentation: https://ej2.syncfusion.com/react/documentation/pivotview/grouping/ |
| 5 | +## 📖 Overview |
6 | 6 |
|
7 | | -Online examples: https://ej2.syncfusion.com/react/demos/#/bootstrap5/pivot-table/grouping |
| 7 | +The **Syncfusion React Pivot Table (PivotView)** is a powerful component for visualizing and analyzing large datasets. In this example: |
8 | 8 |
|
9 | | -## Project prerequisites |
| 9 | +- **Data Source:** A sample dataset with fields like `Date`, `Product_ID`, `Products`, `Sold`, and `Amount`. |
| 10 | +- **Rows:** `Date` (grouped by **Years** and **Months**). |
| 11 | +- **Columns:** `Product_ID` and `Products`. |
| 12 | +- **Values:** |
| 13 | + - `Sold` (Units Sold) |
| 14 | + - `Amount` (Sold Amount) |
| 15 | +- **Grouping Features:** |
| 16 | + - **Date Grouping:** Group by years and months with a custom range. |
| 17 | + - **Custom Grouping:** Combine specific product IDs under a custom group name. |
| 18 | + - **Number Grouping:** (Optional) Group numeric fields by range intervals. |
10 | 19 |
|
11 | | -Make sure that you have the latest versions of NodeJS and Visual Studio Code in your machine before starting to work on this project. |
| 20 | +## ✅ Key Features |
12 | 21 |
|
13 | | -### How to run this application? |
| 22 | +- **Date Grouping:** |
| 23 | + Group dates by intervals such as Years, Months, Quarters, etc. |
| 24 | + ```tsx |
| 25 | + groupSettings: [{ |
| 26 | + name: "Date", |
| 27 | + type: "Date", |
| 28 | + groupInterval: ['Years', 'Months'], |
| 29 | + startingAt: new Date(2015, 6, 1), |
| 30 | + endingAt: new Date(2017, 6, 31) |
| 31 | + }] |
| 32 | + ``` |
14 | 33 |
|
15 | | -To run this application, you need to clone the `group-row-and-column-headers-in-react-pivot-table` repository and then open it in Visual Studio Code. Now, simply install all the necessary react packages into your current project using the `npm install` command and run your project using the `npm start` command. |
| 34 | +- **Custom Grouping:** |
| 35 | + Create custom groups for string fields. |
| 36 | + ```tsx |
| 37 | + { name: "Product_ID", type: "Custom", caption: 'Unsold Products', |
| 38 | + customGroups: [{ groupName: 'Unsold Products', items: ['1004', '1005', '1006'] }] |
| 39 | + } |
| 40 | + ``` |
| 41 | + |
| 42 | +- **Number Grouping:** |
| 43 | + Group numeric fields by range intervals (uncomment in code). |
| 44 | + ```tsx |
| 45 | + { name: "Product_ID", type: "Number", rangeInterval: 3, |
| 46 | + startingAt: 1001, endingAt: 1003 } |
| 47 | + ``` |
| 48 | + |
| 49 | +## 🛠 Prerequisites |
| 50 | + |
| 51 | +Before running this project, ensure you have: |
| 52 | + |
| 53 | +- [Node.js](https://nodejs.org/) (latest version recommended) |
| 54 | +- [Visual Studio Code](https://code.visualstudio.com/) |
| 55 | + |
| 56 | +## 🚀 Getting Started |
| 57 | + |
| 58 | +1. **Clone the repository:** |
| 59 | + ```bash |
| 60 | + git clone https://github.com/SyncfusionExamples/group-row-and-column-headers-in-react-pivot-table |
| 61 | + ``` |
| 62 | + |
| 63 | +2. **Navigate to the project folder:** |
| 64 | + ```bash |
| 65 | + cd group-row-and-column-headers-in-react-pivot-table |
| 66 | + ``` |
| 67 | + |
| 68 | +3. **Install dependencies:** |
| 69 | + ```bash |
| 70 | + npm install |
| 71 | + ``` |
| 72 | + |
| 73 | +4. **Start the development server:** |
| 74 | + ```bash |
| 75 | + npm start |
| 76 | + ``` |
| 77 | + |
| 78 | +5. Open your browser at `http://localhost:3000` to view the Pivot Table. |
| 79 | + |
| 80 | +## 📂 Project Structure |
| 81 | + |
| 82 | +``` |
| 83 | +group-row-and-column-headers-in-react-pivot-table/ |
| 84 | +├── public/ |
| 85 | +│ ├── index.html |
| 86 | +│ └── ... |
| 87 | +├── src/ |
| 88 | +│ ├── App.tsx # Main component with Pivot Table configuration |
| 89 | +│ ├── data.js # Sample data used in the Pivot Table |
| 90 | +│ └── ... |
| 91 | +├── package.json |
| 92 | +├── README.md |
| 93 | +└── tsconfig.json |
| 94 | +``` |
| 95 | + |
| 96 | +## 📚 Learn More |
| 97 | + |
| 98 | +- [Syncfusion React Pivot Table Documentation](https://ej2.syncfusion.com/react/documentation/pivotview/grouping) |
| 99 | +- [Live Demos](https://ej2.syncfusion.com/react/demos/#/bootstrap5/pivot-table/grouping) |
| 100 | + |
| 101 | +## 💬 Support |
| 102 | + |
| 103 | +For questions or feedback, visit: |
| 104 | + |
| 105 | +- [Syncfusion Support Portal](https://support.syncfusion.com) |
| 106 | +- [Syncfusion Community Forums](https://www.syncfusion.com/forums) |
| 107 | + |
| 108 | +## 📜 License |
| 109 | + |
| 110 | +This project uses Syncfusion components, which require a valid license for production use. |
| 111 | +[View Syncfusion License Terms](https://www.syncfusion.com/license/studio/22.2.5/syncfusion_essential_studio_eula.pdf) |
0 commit comments