Member properties in JSON
Data source
HTML
<link rel="stylesheet" href="https://s3.amazonaws.com/flexmonster/2.3/demo.css">
<script src="https://cdn.flexmonster.com/flexmonster.js"></script>
<h3>
Click 'Banana cake' cell to see its product ID
</h3>
<div id="pivot-container"></div>
JavaScript
var pivot = new Flexmonster({
container: "pivot-container",
componentFolder: "https://cdn.flexmonster.com/",
width: "100%",
height: 430,
toolbar: true,
report: {
dataSource: {
data: getData()
},
slice: {
rows: [{uniqueName: "product"}],
columns: [{uniqueName: "[Measures]"}],
measures: [{uniqueName: "price"}]
}
},
cellclick: function(cellDataObject) {
if (cellDataObject.rows[0])
alert("product: " + cellDataObject.rows[0].caption +
", product ID: " +
cellDataObject.rows[0].properties.productID)
}
});
function getData() {
return [
{
"product" : "Banana cake",
"productID" : "0816",
"price" : 24
},
{
"product" : "Chocolate",
"productID" : "2626",
"price" : 31
},
{
"product" : "Chocolate",
"productID" : "2626",
"price" : 56
},{
"product": {
type: "string"
},
"productID":{
type: "hidden",
hierarchy: "product"
},
"price": {
type: "number"
}
}];
}