Flexmonster - Load JSON
Demos
by aivarsak
HTML
<link rel="stylesheet" href="https://s3.amazonaws.com/flexmonster/2.3/demo.css">
<script src="https://cdn.flexmonster.com/flexmonster.js"></script>
<div id="pivot-container"></div>
JavaScript
const customizeCell = (cell, data) => {
const hierarchy = data.hierarchy;
if (hierarchy && data.label) {
if (data.type === 'value') {
if (hierarchy.caption === "Supplier Name") {
cell.text = `<a href="/ID/and/parentID/needed/here">${data.label}</a>`;
}
}
}
}
const pivot = new Flexmonster({
container: "#pivot-container",
componentFolder: "https://cdn.flexmonster.com/",
report: {
dataSource: {
dataSourceType: "json",
data: getData()
},
options: {
grid: { type: 'flat' },
}
},
width: "100%",
height: 370,
customizeCell: customizeCell,
});
function getData() {
return [
{
0: {type: "id"},
1: {caption: "Supplier Name", type: "string"},
2: {caption: "Profit", type: "number"},
3: {caption: "Parent ID", type: "hidden"},
},
[1,"Foo Bars",123.4,22],
[2,"Foo Bars Extra",420.00,22],
];
}