- Home
- Forum
- JavaScript - EJ 2
- Ignore cell value based on condition when aggregate
Ignore cell value based on condition when aggregate
Hi Vangelis,
We understand that you need to customize specific value in the pivot table. If this is the case, you can utilize the aggregateCellInfo event to customize the value cells. In the code example provided below, we have customized the specific value (for instance, 9999) in the "Rate" column by assigning it the average of the previous row values that correspond to the current column. You can adapt this code according to your specific needs.
Please note that you can also access the raw data of a cell using args.cellSets within the event, which allows for additional customization.
Code example:
|
let values = []; aggregateCellInfo: function (args) { // Check if the current cell value is 9999 and customize it if(args.column.valueSort.levelName == 'Rate' && args.value == 9999) { const average = values.reduce((acc, curr) => acc + curr, 0) / values.length; args.value = average } else if(args.column.valueSort.levelName == 'Rate') { // Otherwise store the other values that belong to the 'Rate' column. values.push(args.value) } },
|
Output screenshot:
Before customization:
After customization:
Meanwhile, We have modified the provided sample for your reference. You can find the sample at the following link.
Sample: https://stackblitz.com/edit/e9ut3h-nvvwa9?file=index.js
Furthermore, we have shared the documentation link to know more about aggregateCellInfo event.
Document: https://ej2.syncfusion.com/javascript/documentation/pivotview/aggregation#aggregatecellinfo
Please let us know if you have any concerns.
Regards,
Sridhar Karunakaran.
Excellent !
Thank you for your valuable support
Regards
Vangelis
Hi Vangells,
Thank you for your update. We are delighted to hear that you are satisfied with the solution we provided. If you have any further questions or need assistance, please don't hesitate to contact us. We are always happy to assist you.
Regards,
Angelin Faith Sheeba.
- 3 Replies
- 3 Participants
-
VK Vangelis Komninos
- Nov 10, 2024 06:57 AM UTC
- Nov 12, 2024 05:46 AM UTC