Using AG Grid React, I have a pivot table for orders
that looks like this:
Group | 2010-09-01 | 2010-09-05 | 2010-09-20 |
---|---|---|---|
sum(num_of_packages) | sum(num_of_packages) | sum(num_of_packages) | |
Japan | 1 | 2 | 3 |
USA | 10 | 20 | 30 |
Brazil | 2 | 2 | 4 |
- This table has
pivotMode: true
shipped_at
haspivot: true
location
hasrow_group: true
num_of_packages
hasaggFunc: 'sum'
In short, it is grouping orders by shipped_at
. On 2010-09-01, there were 1 package headed to Japan, 10 to USA, and 2 to Brazil. On 2010-09-05, there were 2 packages headed to Japan, 20 to USA, and 2 to Brazil, etc.
What I’m trying to do is, I want to display all days as columns for the month of September 2010. Any shipments that weren’t recorded would display 0. I want it to look something like this:
Group | 2010-09-01 | 2010-09-02 | 2010-09-03 | 2010-09-04 | 2010-09-05 | etc (all the way to 2010-03-30) |
---|---|---|---|---|---|---|
sum(num_of_packages) | sum(num_of_packages) | sum(num_of_packages) | sum(num_of_packages) | sum(num_of_packages) | sum(num_of_packages) | |
Japan | 1 | 0 | 0 | 0 | 2 | …etc |
USA | 10 | 0 | 0 | 0 | 20 | …etc |
Brazil | 2 | 0 | 0 | 0 | 2 | …etc |
How can I create additional colGroupDefs
for every day in the month that display a default value of 0 if there are no data for those dates?
I’ve looked at the pages related to Pivoting, aggregations custom functions, and other API page (I’m using ag-grid-react
+ enterprise v31.3.2), but didn’t find anything for my use case.