|
1 | | -# Row and Column Options in React Pivot Table |
| 1 | +# Customize Rows and Columns in Syncfusion React Pivot Table |
2 | 2 |
|
3 | | -A quick-start project that shows how to customize the rows and columns of the Syncfusion React Pivot Table component. This project also contains code snippet to resize columns and set gridlines, selection mode, clip mode, and cell templates. |
| 3 | +This sample demonstrates how to **customize the rows and columns** of the Syncfusion **React Pivot Table (PivotView)** component. It includes features like cell templating, column auto-fitting, and interactive grid settings to enhance the user experience. |
4 | 4 |
|
5 | | -Documentation: https://ej2.syncfusion.com/react/documentation/pivotview/row-and-column/ |
| 5 | +## 📖 Overview |
6 | 6 |
|
7 | | -Online examples: https://ej2.syncfusion.com/react/demos/#/bootstrap5/pivot-table/cell-template |
| 7 | +The **Syncfusion Pivot Table** is a powerful React component used for data analysis and visualization. In this example, we use a sample dataset to display sales information across different countries, products, and years. |
8 | 8 |
|
9 | | -## Project prerequisites |
| 9 | +Key configurations include: |
10 | 10 |
|
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. |
| 11 | +- **Rows:** `Country`, `Products` |
| 12 | +- **Columns:** `Year` |
| 13 | +- **Values:** `Sold` (Units Sold), `Amount` (Total Sold Amount) |
| 14 | +- **Excluded Fields:** `Products`, `Quarter` |
12 | 15 |
|
13 | | -### How to run this application? |
| 16 | +The Pivot Table is customized with: |
14 | 17 |
|
15 | | -To run this application, you need to clone the `row-and-column-options-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. |
| 18 | +- A **cell template** for styling individual cells. |
| 19 | +- **Auto-fitting columns** using the `columnRender` event. |
| 20 | +- Enhanced **grid settings** like resizing, reordering, selection, and tooltip clipping. |
| 21 | + |
| 22 | +## ✅ Features Demonstrated |
| 23 | + |
| 24 | +- **Cell Template Customization:** |
| 25 | + A custom cell template is used to style cells with a neutral appearance. |
| 26 | + ```tsx |
| 27 | + const customizeCell = () => { |
| 28 | + return (<span className='tempwrap e-pivot-neutral'></span>); |
| 29 | + }; |
| 30 | + ``` |
| 31 | + |
| 32 | +- **Auto-Fit Columns:** |
| 33 | + Automatically adjusts column widths for better readability. |
| 34 | + ```tsx |
| 35 | + const columnFit = (props: any) => { |
| 36 | + for (let i = 0; i < props.columns.length; i++) { |
| 37 | + props.columns[i].autoFit = true; |
| 38 | + } |
| 39 | + }; |
| 40 | + ``` |
| 41 | + |
| 42 | +- **Grid Settings:** |
| 43 | + Includes features like: |
| 44 | + - Row height customization |
| 45 | + - Column resizing and reordering |
| 46 | + - Cell selection with box mode |
| 47 | + - Grid lines and tooltip clipping |
| 48 | + |
| 49 | +## 🛠 Prerequisites |
| 50 | + |
| 51 | +Before running this project, make sure you have: |
| 52 | + |
| 53 | +- [Node.js](https://nodejs.org/) installed |
| 54 | +- [Visual Studio Code](https://code.visualstudio.com/) or any code editor |
| 55 | + |
| 56 | +## 🚀 Getting Started |
| 57 | + |
| 58 | +Follow these steps to run the project locally: |
| 59 | + |
| 60 | +1. **Clone the repository:** |
| 61 | + ```bash |
| 62 | + git clone https://github.com/SyncfusionExamples/row-and-column-options-in-react-pivot-table |
| 63 | + ``` |
| 64 | + |
| 65 | +2. **Navigate to the project folder:** |
| 66 | + ```bash |
| 67 | + cd react-pivot-table-customization |
| 68 | + ``` |
| 69 | + |
| 70 | +3. **Install dependencies:** |
| 71 | + ```bash |
| 72 | + npm install |
| 73 | + ``` |
| 74 | + |
| 75 | +4. **Start the development server:** |
| 76 | + ```bash |
| 77 | + npm start |
| 78 | + ``` |
| 79 | + |
| 80 | +5. Open your browser and go to `http://localhost:3000` to view the Pivot Table. |
| 81 | + |
| 82 | +## 📂 Project Structure |
| 83 | + |
| 84 | +``` |
| 85 | +react-pivot-table-customization/ |
| 86 | +├── public/ |
| 87 | +│ ├── index.html |
| 88 | +│ └── ... |
| 89 | +├── src/ |
| 90 | +│ ├── App.tsx # Main component with Pivot Table customization |
| 91 | +│ ├── data.js # Sample data used in the Pivot Table |
| 92 | +│ ├── App.css # Custom styles |
| 93 | +│ └── ... |
| 94 | +├── package.json |
| 95 | +├── README.md |
| 96 | +└── tsconfig.json |
| 97 | +``` |
| 98 | + |
| 99 | +## 📊 Sample Data |
| 100 | + |
| 101 | +The Pivot Table uses a sample dataset with the following fields: |
| 102 | + |
| 103 | +```js |
| 104 | +[ |
| 105 | + { |
| 106 | + 'Sold': 31, |
| 107 | + 'Amount': 52824, |
| 108 | + 'Country': 'France', |
| 109 | + 'Products': 'Mountain Bikes', |
| 110 | + 'Year': 'FY 2015', |
| 111 | + 'Quarter': 'Q1' |
| 112 | + }, |
| 113 | + { |
| 114 | + 'Sold': 51, |
| 115 | + 'Amount': 86904, |
| 116 | + 'Country': 'France', |
| 117 | + 'Products': 'Mountain Bikes', |
| 118 | + 'Year': 'FY 2015', |
| 119 | + 'Quarter': 'Q2' |
| 120 | + } |
| 121 | +] |
| 122 | +``` |
| 123 | + |
| 124 | +## 📚 Learn More |
| 125 | + |
| 126 | +- [Syncfusion React Pivot Table Documentation](https://ej2.syncfusion.com/react/documentation/pivotview/getting-started/) |
| 127 | +- [Live Demos](https://ej2.syncfusion.com/react/demos/#/bootstrap5/pivot-table/default) |
| 128 | + |
| 129 | +## 💬 Support |
| 130 | + |
| 131 | +For questions or feedback, visit: |
| 132 | + |
| 133 | +- [Syncfusion Support Portal](https://support.syncfusion.com) |
| 134 | +- [Syncfusion Community Forums](https://www.syncfusion.com/forums) |
| 135 | + |
| 136 | +## 📜 License |
| 137 | + |
| 138 | +This project uses Syncfusion components, which require a valid license for production use. |
| 139 | +[View Syncfusion License Terms](https://www.syncfusion.com/license/studio/22.2.5/syncfusion_essential_studio_eula.pdf) |
0 commit comments