具有 json 数据的 EXTJS 数据透视表

EXTJS Pivot Grid with json data

我是 EXTJS 的新手。现在我正在尝试开发简单的枢轴网格示例。我的代码是:

  Ext.onReady(function () {
  var myStore = new Ext.data.ArrayStore({
    autoLoad: true,
    fields: ['gender',
        { name: 'birthDecade', type: 'int' },
        { name: 'peoples', type: 'int' }
    ],

    url: 'countries.json'
});
var pivotGrid = new Ext.grid.PivotGrid({
    title: 'Number of people born per decade',
    width: 600,
    height: 91,
    renderTo: 'docbody',
    store: myStore,
    aggregator: 'count',

    topAxis: [
        {
            width: 80,
            dataIndex: 'birthDecade'
        }
    ],
    leftAxis: [
        {

            dataIndex: 'gender'
        }
    ],


});

});

JSON 数据:

 [["Male","2010","1"],
 ["Female","1940","2"],
 ["Male","1960","3"],
 ["Female","1980","4"],
 ["Female","2000","5"],
 ["Male","2010","5"],
 ["Male","2030","6"],
 ["Female","1000","7"]]

输出是:

但我想显示我在 json 中提供的数据(第 3 个 column.values-1,2,3,4,5,6,7)。如何实现?提前致谢。

当你使用计数作为聚合器时,它的显示就是这样。 2000 年有一位女性伯爵。同样在 2010 年,有两排男性计数。所以才会这样显示。 如果你想在输出中显示一些数字,你可以这样使用,

Ext.onReady(function () {
var myStore = new Ext.data.ArrayStore({
    autoLoad: true,
    fields: ['gender',
        { name: 'birthDecade', type: 'int' },
        { name: 'peoples', type: 'int' }
    ],

    url: 'countries.json'
});
var pivotGrid = new Ext.grid.PivotGrid({
    title: 'Number of people born per decade',
    width: 600,
    height: 91,
    renderTo: 'docbody',
    store: myStore,
    aggregator: 'sum',
    measure: 'peoples',

    topAxis: [
        {
            width: 80,
            dataIndex: 'birthDecade'
        }
    ],
    leftAxis: [
        {

            dataIndex: 'gender'
        }
    ],


});

});