简体   繁体   English

带有JSON数据的EXTJS数据透视网格

[英]EXTJS Pivot Grid with json data

I am new to EXTJS. 我是EXTJS的新手。 Now im trying to develop simple pivot grid example. 现在,我正在尝试开发简单的枢轴网格示例。 my code is: 我的代码是:

  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 DATA : 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"]]

And output is : 输出为: 在此处输入图片说明

But i want to show data that i gave in json (3rd column.values-1,2,3,4,5,6,7). 但我想显示我在json中提供的数据(第3 column.values-1,2,3,4,5,6,7)。 how to achieve it?.thanks in advance. 如何实现呢?。在此先感谢。

As u used count as aggregator its shows like that. 当您使用计数作为聚合器时,显示如下。 in 2000 one female count is there . 在2000年有一位女性伯爵。 for same in 2010 two rows of male count there . 对于2010年同样的情况,那里有两排男性。 So that it shows like that. 如此显示。 If u want to show some numbers in output u can use like this, 如果您想在输出中显示一些数字,可以这样使用:

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'
        }
    ],


});

}); });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM