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
new Flexmonster({
container: "#pivot-container",
componentFolder: "https://cdn.flexmonster.com/",
width: "100%",
height: "400",
toolbar: true,
customizeCell: function(cell, data) {
if (data.member != null && data.member.properties != null && data.member.properties["Item Desc"] != null) {
var el = document.createElement('div');
el.innerHTML = cell.text;
var parts = cell.text.split(el.innerText);
if (parts.length == 2) {
cell.text = parts[0] + data.member.properties["Item Desc"] + parts[1];
} else {
cell.text = data.member.properties["Item Desc"];
}
}
},
report: {
dataSource: {
dataSourceType: "json",
data: getData()
},
slice: {
"rows": [
{
"uniqueName": "Item Id"
},
{
"uniqueName": "Store Id"
}
],
"columns": [
{
"uniqueName": "[Measures]"
}
],
"measures": [
{
"uniqueName": "Price",
"aggregation": "sum"
},
{
"uniqueName": "Quantity",
"aggregation": "sum"
},
{
"uniqueName": "Discount",
"aggregation": "sum"
}
]
},
conditions: [],
formats: []
}
});
function getData() {
return [
{
"Item Id": {
type: "string"
},
"Item Desc": {
type: "property",
hierarchy: "Item Id"
},
"Store Id": {
type: "string"
},
"Store Desc": {
type: "property",
hierarchy: "Store Id"
},
"Price": {
type: "number"
},
"Quantity": {
type: "number"
},
"Discount": {
type: "number"
},
"Date": {
type: "date string"
}
},{
"Item Id": "ITM01",
"Item Desc": "Desc. Item 01",
"Store Id": "STR02",
"Store Desc": "Desc. Store 02",
...