|
1 | | -# Getting Started with React UI Components using Next.js |
| 1 | +# 📊 Getting Started — React Pivot Table Component (Syncfusion EJ2) + Next.js |
2 | 2 |
|
3 | | -This application demonstrates the usage of the Syncfusion React Pivot Table component in Next.js. |
| 3 | +[](https://www.syncfusion.com/content/downloads/syncfusion_license.pdf) |
| 4 | +[](https://nextjs.org/) |
| 5 | +[](https://github.com/SyncfusionExamples/syncfusion-react-pivotview-component-in-nextjs/commits) |
| 6 | +[](https://www.syncfusion.com/react-components/) |
| 7 | +[](https://nodejs.org/) |
| 8 | +[](https://www.npmjs.com/) |
4 | 9 |
|
5 | | -To know how to configure the Syncfusion React Pivot Table component in Next.js, refer to the [documentation](https://ej2.syncfusion.com/react/documentation/pivotview/nextjs-getting-started). |
| 10 | +A small Next.js sample showcasing how to integrate the Syncfusion React Pivot Table (PivotView) component with the Next.js App Router. This repo demonstrates a client-side `app/page.tsx` usage, sample datasource and theme imports so you can run the demo locally in minutes. 🚀 |
6 | 11 |
|
7 | | -## Clone the repository |
| 12 | +## 🔍 Quick overview |
8 | 13 |
|
9 | | -* To clone the sample repository locally, open the command prompt in the desired location and execute the following command. |
| 14 | +- What: Example Next.js app that integrates the Syncfusion React Pivot Table (`@syncfusion/ej2-react-pivotview`). |
| 15 | +- Why: Shows how to use Syncfusion interactive components with the Next.js App Router (client components + CSS imports). |
| 16 | +- Who: Frontend developers building data-visualization dashboards using React + Next.js. |
10 | 17 |
|
11 | | -```sh |
| 18 | +## ✨ Key Features |
12 | 19 |
|
13 | | -git clone https://github.com/SyncfusionExamples/ej2-nextjs-pivotview.git |
| 20 | +| Feature | Description | Benefit | |
| 21 | +|---------|-------------|---------| |
| 22 | +| 🎯 **Field List Interface** | Dynamically add, remove, and rearrange data fields at runtime | Empowers end-users to customize reports without code modifications | |
| 23 | +| 📊 **Flexible Data Binding** | Supports relational data binding with hierarchical structures | Handle complex multi-dimensional business data | |
| 24 | +| 🧮 **Calculated Fields** | Create custom formulas combining multiple data fields | Advanced data analysis and business metric computation | |
| 25 | +| 💱 **Data Formatting** | Display values in currency, percentages, and custom formats | Professional presentation of numerical data | |
| 26 | +| ↕️ **Multi-Level Sorting** | Sort by multiple fields with ascending/descending control | Enhanced data exploration and trend analysis | |
| 27 | +| 🔗 **Advanced Filtering** | Filter by single or multiple criteria across all dimensions | Focused data analysis and drill-down exploration | |
| 28 | +| 📱 **Responsive Design** | Adapts seamlessly to desktop, tablet, and mobile screens | Universal accessibility across all devices | |
| 29 | +| 📤 **Export Functionality** | Export pivot table data to Excel and PDF formats | Generate shareable reports and archives | |
| 30 | +| 🎨 **Theme Support** | Multiple Tailwind and Bootstrap themes available | Consistent branding and visual customization | |
| 31 | +| ⚡ **Performance Optimized** | Efficient rendering with virtual scrolling | Handle large datasets without performance degradation | |
14 | 32 |
|
15 | | -``` |
16 | 33 |
|
17 | | -* Navigate to the project directory: |
| 34 | +## ✅ Highlights |
18 | 35 |
|
19 | | -```sh |
20 | | -cd ej2-nextjs-pivotview |
21 | | -``` |
| 36 | +- Ready-to-run demo with sample `pivotData`. |
| 37 | +- Uses Syncfusion module injection (`CalculatedField`, `FieldList`). |
| 38 | +- Shows theme / CSS imports to `app/globals.css` for consistent styling. |
| 39 | + |
| 40 | +## 🔧 Prerequisites |
22 | 41 |
|
23 | | -## Installing Packages |
| 42 | +- Node.js 18 LTS or later |
| 43 | +- npm (or yarn) |
24 | 44 |
|
25 | | -Install the required node modules by running the following command: |
| 45 | +## 🚀 Quick start |
26 | 46 |
|
27 | | -```sh |
| 47 | +Clone, install and run the app locally: |
| 48 | + |
| 49 | +```bash |
| 50 | +git clone https://github.com/SyncfusionExamples/syncfusion-react-pivotview-component-in-nextjs |
| 51 | +cd syncfusion-react-pivotview-component-in-nextjs |
28 | 52 | npm install |
| 53 | +npm run dev |
29 | 54 | ``` |
30 | 55 |
|
31 | | -## Run the application |
| 56 | +Open http://localhost:3000 to view the running sample. |
32 | 57 |
|
33 | | -To run the application, use the following command: |
| 58 | +--- |
| 59 | + |
| 60 | +## 📁 What’s included |
| 61 | + |
| 62 | +- `app/datasource.tsx` — sample `pivotData` used by the demo. |
| 63 | +- `app/page.tsx` — client component mounting `PivotViewComponent` and injecting services. |
| 64 | +- `app/globals.css` — recommended place to add Syncfusion theme CSS imports. |
| 65 | + |
| 66 | +## 🔌 How this sample was prepared (key steps) |
| 67 | + |
| 68 | +1. Install the Syncfusion PivotView package: |
34 | 69 |
|
35 | 70 | ```bash |
36 | | -npm run dev |
| 71 | +npm install @syncfusion/ej2-react-pivotview --save |
37 | 72 | ``` |
| 73 | + |
| 74 | +2. Import Syncfusion theme CSS into `app/globals.css` (example Tailwind3 theme imports): |
| 75 | + |
| 76 | +```css |
| 77 | +@import '../node_modules/@syncfusion/ej2-base/styles/tailwind3.css'; |
| 78 | +@import '../node_modules/@syncfusion/ej2-buttons/styles/tailwind3.css'; |
| 79 | +@import '../node_modules/@syncfusion/ej2-dropdowns/styles/tailwind3.css'; |
| 80 | +@import '../node_modules/@syncfusion/ej2-grids/styles/tailwind3.css'; |
| 81 | +@import '../node_modules/@syncfusion/ej2-inputs/styles/tailwind3.css'; |
| 82 | +@import '../node_modules/@syncfusion/ej2-lists/styles/tailwind3.css'; |
| 83 | +@import '../node_modules/@syncfusion/ej2-navigations/styles/tailwind3.css'; |
| 84 | +@import '../node_modules/@syncfusion/ej2-popups/styles/tailwind3.css'; |
| 85 | +@import '../node_modules/@syncfusion/ej2-splitbuttons/styles/tailwind3.css'; |
| 86 | +@import '../node_modules/@syncfusion/ej2-calendars/styles/tailwind3.css'; |
| 87 | +@import '../node_modules/@syncfusion/ej2-react-pivotview/styles/tailwind3.css'; |
| 88 | +/* add other component CSS as needed */ |
| 89 | +``` |
| 90 | + |
| 91 | +3. Make `app/page.tsx` a client component and mount `PivotViewComponent`: |
| 92 | + |
| 93 | +```tsx |
| 94 | +'use client' |
| 95 | +import { CalculatedField, FieldList, Inject, PivotViewComponent } from '@syncfusion/ej2-react-pivotview'; |
| 96 | +import { DataSourceSettingsModel } from '@syncfusion/ej2-pivotview/src/model/datasourcesettings-model'; |
| 97 | +import { pivotData } from './datasource'; |
| 98 | + |
| 99 | +export default function Home() { |
| 100 | + const dataSourceSettings: DataSourceSettingsModel = { |
| 101 | + columns: [{ name: 'Year', caption: 'Production Year' }, { name: 'Quarter' }], |
| 102 | + dataSource: pivotData as any[], |
| 103 | + expandAll: false, |
| 104 | + filters: [], |
| 105 | + drilledMembers: [{ name: 'Country', items: ['Germany'] }], |
| 106 | + formatSettings: [{ name: 'Amount', format: 'C0' }], |
| 107 | + rows: [{ name: 'Country' }, { name: 'Products' }], |
| 108 | + values: [{ name: 'Sold', caption: 'Units Sold' }, { name: 'Amount', caption: 'Sold Amount' }] |
| 109 | + }; |
| 110 | + |
| 111 | + return ( |
| 112 | + <> |
| 113 | + <h2>Syncfusion React Pivot Table Component</h2> |
| 114 | + <PivotViewComponent id='PivotView' height={350} dataSourceSettings={dataSourceSettings} allowCalculatedField={true} showFieldList={true}><Inject services={[CalculatedField, FieldList]} /> |
| 115 | + </PivotViewComponent> |
| 116 | + </> |
| 117 | + ) |
| 118 | +} |
| 119 | +``` |
| 120 | + |
| 121 | +4. Provide sample `pivotData` in `app/datasource.tsx` (array of objects) — the demo ships with this file. |
| 122 | + |
| 123 | +--- |
| 124 | + |
| 125 | +## ⚙️ Configuration & customization |
| 126 | + |
| 127 | +- Theme: Swap the Tailwind3 CSS imports to a different Syncfusion theme file if you prefer (e.g., `fabric.css`, `material.css`). |
| 128 | +- Localization: Use Syncfusion localization utilities if needed. |
| 129 | +- Lazy-loading: Consider dynamic imports for PivotView if server-side rendering is used elsewhere. |
| 130 | + |
| 131 | +## 🧩 Files structure (important files) |
| 132 | + |
| 133 | +- `app/datasource.tsx` — sample data |
| 134 | +- `app/page.tsx` — demo page (client component) |
| 135 | +- `app/globals.css` — place to import Syncfusion themes |
| 136 | +- `next.config.js`, `package.json`, `tsconfig.json` — project configs |
| 137 | + |
| 138 | +--- |
| 139 | + |
| 140 | +## 🛠 Troubleshooting |
| 141 | + |
| 142 | +- If components don’t style correctly, ensure the theme CSS is imported into `app/globals.css` and there are no conflicting global rules. |
| 143 | +- If interactive features fail, verify `app/page.tsx` includes `'use client'` at the top. |
| 144 | + |
| 145 | +--- |
| 146 | + |
| 147 | +## 🤝 Contributing |
| 148 | + |
| 149 | +We welcome contributions! Here's how you can help: |
| 150 | + |
| 151 | +1. **Fork** the repository |
| 152 | +2. **Create** a feature branch (`git checkout -b feature/amazing-feature`) |
| 153 | +3. **Commit** your changes (`git commit -m 'Add amazing feature'`) |
| 154 | +4. **Push** to the branch (`git push origin feature/amazing-feature`) |
| 155 | +5. **Open** a Pull Request |
| 156 | + |
| 157 | +--- |
| 158 | + |
| 159 | +## 📜 License & Support |
| 160 | + |
| 161 | +### License |
| 162 | + |
| 163 | +This project is licensed under the **Syncfusion Community License**. See the [Syncfusion License](https://www.syncfusion.com/content/downloads/syncfusion_license.pdf) for details. |
| 164 | + |
| 165 | +### Support & Resources |
| 166 | + |
| 167 | +- 📚 **Official Documentation:** [Syncfusion React PivotView](https://ej2.syncfusion.com/react/documentation/pivotview/nextjs-getting-started) |
| 168 | +- 🎬 **Video Tutorials:** [Syncfusion YouTube Channel](https://www.youtube.com/c/SyncfusionInc) |
| 169 | +- 💬 **Support Forum:** [Syncfusion Support](https://www.syncfusion.com/forums/react-js2) |
| 170 | +- 🐛 **Report Issues:** [GitHub Issues](https://github.com/SyncfusionExamples/syncfusion-react-pivotview-component-in-nextjs/issues) |
| 171 | +- 📧 **Contact Us:** support@syncfusion.com |
| 172 | + |
| 173 | +### Additional Resources |
| 174 | + |
| 175 | +- 🔗 [Syncfusion React Components](https://www.syncfusion.com/react-components/) |
| 176 | +- 📖 [Syncfusion Community](https://www.syncfusion.com/forums/react-js2) |
| 177 | +- 🎯 [Demo Sample](https://ej2.syncfusion.com/nextjs/demos/tailwind3/pivot-table/overview) |
| 178 | + |
| 179 | +--- |
| 180 | + |
| 181 | +## ⚡ Performance Tips |
| 182 | + |
| 183 | +- ✅ Use **virtual scrolling** for large datasets (1000+ rows) |
| 184 | +- ✅ Enable **lazy loading** for remote data sources |
| 185 | +- ✅ Optimize **format settings** to reduce rendering overhead |
| 186 | +- ✅ Use **filter and drill-down** to reduce data volume displayed |
| 187 | +- ✅ Consider **server-side aggregation** for very large datasets |
| 188 | + |
| 189 | +--- |
0 commit comments