JSFiddle - React, Tailwind, and code Playground
by Flexmonster Pivot Table
HTML
<script src="https://cdn.flexmonster.com/flexmonster.js"></script>
<div id="pivot-container"></div>
JavaScript
let accounts = [{
"customerId": 11651,
"streetAddress": "256 Rio Clara Dr",
"city": "Chicago",
"postalCode": "60610",
"state": "IL",
"country": "USA",
"email": "marv-marola@example.gov",
"phone": "670-018-7377",
"accountCreated": "2014-08-12",
"isHNW": true,
"accounts": [{
"accountId": 3567361088,
"accountBalance": 9453.563,
"created": "2014-09-21"
}, {
"accountId": 3567361090,
"accountBalance": 109453.563,
"created": "2014-10-21"
}]
},
{
"customerId": 11652,
"streetAddress": "12 Rodeo Dr",
"city": "Hollywood",
"postalCode": "70610",
"state": "CA",
"country": "USA",
"email": "donn-marola@example.gov",
"phone": "670-018-7377",
"accountCreated": "2014-08-12",
"isHNW": false,
"accounts": [{
"accountId": 4567361088,
"accountBalance": 9453.563,
"created": "2014-09-21"
}]
}
];
let pivot = new Flexmonster({
container: "pivot-container",
componentFolder: "https://cdn.flexmonster.com/",
toolbar: true,
report: {
dataSource: {
data: formatData(accounts),
mapping: {
"customerId": {type: "string"},
"streetAddress": {type: "string"},
"city": {type: "string"},
"postalCode": {type: "string"},
"state": {type: "string"},
"country": {type: "string"},
"email": {type: "string"},
"phone": {type: "string"},
"accountCreated": {type: "date string"},
"isHNW": {type: "string"},
"accountId": {type: "string"},
"accountBalance": {type: "number"},
"created": {type: "date string"}
}
},
options: {
grid: {
type: "flat",
showGrandTotals: "off"
}
}
}
});
function formatData(data) {
let customerAccounts = [];
data.forEach(customer => {
let accounts = customer.accounts;
customer.accounts = null;
delete customer.accounts;
accounts.forEach(account =>...