Code:
Ext.onReady(function() {
var SaleRecord = Ext.data.Record.create([
{name: 'name', type: 'string'},
{name: 'color', type: 'string'},
{name: 'thick', type: 'string'},
{name: 'price', type: 'int'}
]);
var myStore = new Ext.data.Store({
url: 'simple.json',
autoLoad: true,
reader: new Ext.data.JsonReader({
root: 'rows',
idProperty: 'id'
}, SaleRecord)
});
var pivotGrid = new Ext.grid.PivotGrid({
title : 'PivotGrid example',
anchor : "100%",
height : 259,
renderTo : document.body,
store : myStore,
aggregator: 'sum',
measure : 'price',
viewConfig: {
title: 'Name'
},
leftAxis: [
{
width: 80,
dataIndex: 'name'
}
],
topAxis: [
{
dataIndex: 'color'
},
{
dataIndex: 'thick'
}
]
});
});
simple.json
Code:
{
"rows": [{
"id": "1",
"name": "test01",
"color": "black",
"thick": "0.1 mm",
"price": "200"
},{
"id": "2",
"name": "test01",
"color": "black",
"thick": "0.2 mm",
"price": "400"
},{
"id": "3",
"name": "test01",
"color": "black",
"thick": "0.3 mm",
"price": "400"
},{
"id": "4",
"name": "test01",
"color": "black",
"thick": "0.4 mm",
"price": "400"
},{
"id": "5",
"name": "test01",
"color": "white",
"thick": "0.1 mm",
"price": "200"
},{
"id": "6",
"name": "test01",
"color": "white",
"thick": "0.2 mm",
"price": "400"
},{
"id": "7",
"name": "test01",
"color": "white",
"thick": "0.3 mm",
"price": "400"
},{
"id": "8",
"name": "test01",
"color": "white",
"thick": "0.4 mm",
"price": "400"
},{
"id": "9",
"name": "test02",
"color": "black",
"thick": "0.1 mm",
"price": "200"
},{
"id": "10",
"name": "test02",
"color": "black",
"thick": "0.2 mm",
"price": "400"
},{
"id": "11",
"name": "test02",
"color": "black",
"thick": "0.3 mm",
"price": "400"
},{
"id": "12",
"name": "test02",
"color": "black",
"thick": "0.4 mm",
"price": "400"
},{
"id": "13",
"name": "test02",
"color": "white",
"thick": "0.1 mm",
"price": "200"
},{
"id": "14",
"name": "test02",
"color": "white",
"thick": "0.2 mm",
"price": "400"
},{
"id": "15",
"name": "test02",
"color": "white",
"thick": "0.3 mm",
"price": "400"
},{
"id": "16",
"name": "test02",
"color": "white",
"thick": "0.4 mm",
"price": "400"
}]
}
help me please.