PDA

View Full Version : Pivot table



christophe67
18 May 2011, 6:42 AM
Hello,

I need to build a pivot table, but the header and the left axis doesn't show.
Can anybody help me, I don't what is wrong in my code.


var pivot_store = new Ext.data.Store({
url : 'sources/data_pagging_gptt.php',
baseParams:{task: "pivot"},
autoLoad: true,
reader: new Ext.data.JsonReader({
root: 'results',
idProperty: 'id_matrice_coeff'
}, recordpivottable)
});

pivot_store.load();
var pivot_table= new Ext.grid.PivotGrid({
width : 800,
height : 559,
border:false,
layout :'fit',
store : pivot_store,
aggregator: 'count',
measure : 'etat',


leftAxis: [
{
width: 80,
dataIndex: 'reference'
}
],

topAxis: [
{
dataIndex: 'niveau'

}
]
})
thank for your help :)

christophe67
19 May 2011, 1:19 AM
Please can anybody help me, I need this for finish my project

Thanks

fay
19 May 2011, 4:45 AM
What does your recordpivottable definition look like and do you have some sample data to test with?

christophe67
19 May 2011, 5:58 AM
This is my data

({"results":[{"0":"GPTT","categorie":"GPTT","1":"SEL-F-JIB-JCT-001","reference":"SEL-F-JIB-JCT-001","2":"Montage toile sur machine \u00e0 jonctionner","description":"","3":"JONCTION","atelier":"Jonction","4":"prepa","description_niveau1":"prepa","5":"Experimente","niveau":"Experimente","6":"170","coeff":"170","7":"Jonction","8":""},{"0":"Leadership","categorie":"Leadership","1":"L0001","reference":"L0001","2":"test","description":"","3":"JONCTION","atelier":"Jonction","4":"prepa","description_niveau1":"prepa","5":"Experimente","niveau":"Experimente","6":"170","coeff":"170","7":"Jonction","8":""},{"0":"GPTT","categorie":"GPTT","1":"SEL-F-JIB-JCT-001","reference":"SEL-F-JIB-JCT-001","2":"Montage toile sur machine \u00e0 jonctionner","description":"","3":"JONCTION","atelier":"Jonction","4":"prepa","description_niveau1":"prepa","5":"Experimente","niveau":"Experimente","6":"170","coeff":"170","7":"Jonction","8":""},{"0":"GPTT","categorie":"GPTT","1":"SEL-F-JIB-JCT-002","reference":"SEL-F-JIB-JCT-002","2":"D\u00e9montage toile sur machine \u00e0 jonctionner","description":"","3":"JONCTION","atelier":"JONCTION","4":"preparateur Chainette","description_niveau1":"preparateur Chainette","5":"Experimente","niveau":"Experimente","6":"180","coeff":"180","7":"JONCTION","8":""}]})
Thanks for your help

fay
19 May 2011, 9:29 AM
And your recordpivottable record definition...

christophe67
19 May 2011, 9:22 PM
This is my record table


var recordpivottable= Ext.data.Record.create([
{ name: 'id_matrice_coeff', mapping: 'id_matrice_coeff', type: 'string'},
{ name : 'description_niveau1', mapping :'description_niveau1', type: 'string'},
{ name : 'niveau', mapping :'niveau', type: 'string'},
{ name : 'coeff', mapping :'coeff', type: 'string'},
{ name : 'categorie', mapping :'categorie', type: 'string'},
{ name : 'reference', mapping :'reference', type: 'string'},
{ name : 'description', mapping :'description', type: 'string'},
{ name : 'etat', mapping :'etat', type: 'int'}
]);

fay
20 May 2011, 1:21 AM
I tried your data and code in the \examples\pivotgrid\simple.js example and it works okay, apart from missing a viewConfig | title setting.

test.json



{
"results": [
{
"0": "GPTT",
"categorie": "GPTT",
"1": "SEL-F-JIB-JCT-001",
"reference": "SEL-F-JIB-JCT-001",
"2": "Montage toile sur machine \\u00e0 (file://u00e0/) jonctionner",
"description": "",
"3": "JONCTION",
"atelier": "Jonction",
"4": "prepa",
"description_niveau1": "prepa",
"5": "Experimente",
"niveau": "Experimente",
"6": "170",
"coeff": "170",
"7": "Jonction",
"8": ""
},
{
"0": "Leadership",
"categorie": "Leadership",
"1": "L0001",
"reference": "L0001",
"2": "test",
"description": "",
"3": "JONCTION",
"atelier": "Jonction",
"4": "prepa",
"description_niveau1": "prepa",
"5": "Experimente",
"niveau": "Experimente",
"6": "170",
"coeff": "170",
"7": "Jonction",
"8": ""
},
{
"0": "GPTT",
"categorie": "GPTT",
"1": "SEL-F-JIB-JCT-001",
"reference": "SEL-F-JIB-JCT-001",
"2": "Montage toile sur machine \\u00e0 (file://u00e0/) jonctionner",
"description": "",
"3": "JONCTION",
"atelier": "Jonction",
"4": "prepa",
"description_niveau1": "prepa",
"5": "Experimente",
"niveau": "Experimente",
"6": "170",
"coeff": "170",
"7": "Jonction",
"8": ""
},
{
"0": "GPTT",
"categorie": "GPTT",
"1": "SEL-F-JIB-JCT-002",
"reference": "SEL-F-JIB-JCT-002",
"2": "D\\u00e9montage toile sur machine \\u00e0 (file://u00e0/) jonctionner",
"description": "",
"3": "JONCTION",
"atelier": "JONCTION",
"4": "preparateur Chainette",
"description_niveau1": "preparateur Chainette",
"5": "Experimente",
"niveau": "Experimente",
"6": "180",
"coeff": "180",
"7": "JONCTION",
"8": ""
}
]
}


test.js



Ext.onReady(function() {
var recordpivottable = Ext.data.Record.create([
{ name: 'id_matrice_coeff', mapping: 'id_matrice_coeff', type: 'string'},
{ name : 'description_niveau1', mapping :'description_niveau1', type: 'string'},
{ name : 'niveau', mapping :'niveau', type: 'string'},
{ name : 'coeff', mapping :'coeff', type: 'string'},
{ name : 'categorie', mapping :'categorie', type: 'string'},
{ name : 'reference', mapping :'reference', type: 'string'},
{ name : 'description', mapping :'description', type: 'string'},
{ name : 'etat', mapping :'etat', type: 'int'}
]);

var pivot_store = new Ext.data.Store({
url : 'test.json',
//baseParams:{task: "pivot"},
autoLoad: true,
reader: new Ext.data.JsonReader({
root: 'results',
idProperty: 'id_matrice_coeff'
}, recordpivottable)
});

var pivot_table= new Ext.grid.PivotGrid({
width : 800,
height : 559,
border:false,
renderTo : 'docbody',
//layout :'fit',
store : pivot_store,
aggregator: 'count',
measure : 'etat',
viewConfig: {
title: 'Reference'
},
leftAxis: [
{
width: 80,
dataIndex: 'reference'
}
],
topAxis: [
{
dataIndex: 'niveau'
}
]
});
});

christophe67
20 May 2011, 1:34 AM
Hello Fay,

Thanks for your help I tried the view configuration but the result is show in the picture attached.