在EasyUI PivotGrid中使用多级数据

时间:2017-12-31 09:04:57

标签: javascript pivot jquery-easyui

pivotgrid可以获取一组对象。您可以选择数组字段作为行或列来创建数据透视表。 :

var data = [{

    "ProjectName": "Company Holiday",
    "OrderNumber": "123",
    "Hrs": 8,
    "ResourceName": "Gilly",
    "ForecastMonth": "Dec-16",
    "FcDate":"12-16"
}, {
    "status" : "true",
    "ProjectName": "Company Holiday",
    "OrderNumber": "123",
    "Hrs": 8,
    "ResourceName": "Bill",
    "ForecastMonth": "Apr-16",
    "FcDate":"04-16"
}];
$(function() {
  $('#pg').pivotgrid({
    pivot: {
    rows: ['ProjectName', 'ResourceName'],
    columns: ['ForecastMonth'],
    values: [{
    field: 'Hrs',
    op: 'sum'
  }],
 },
data: data
});
});

,但我的数据是多层次的。我无法将它们安排在一个层面上。这是我的数组的简单示例:

var data = [{
"ProjectName": "Company Holiday",
"OrderNumber": "123",
"item: {
  "Hrs": 8
},
"ResourceName": "Gilly",
"ForecastMonth": "Dec-16",
"FcDate":"12-16"
}, 
{
"ProjectName": "Company Holiday",
"OrderNumber": "123",
 "item:: {
  "Hrs": 8
},
"ResourceName": "Bill",
"ForecastMonth": "Apr-16",
"FcDate":"04-16"
}];

现在如果我的数组对象中有一个对象,如何设置pivot的行和列? 这里是JSFiddle代码: http://jsfiddle.net/zgxege1w/59/

0 个答案:

没有答案