【问题标题】:jqPivot- how do I just show the data rows and not summary headers?jqPivot-我如何只显示数据行而不是摘要标题?
【发布时间】:2016-01-25 21:02:26
【问题描述】:

我正在尝试构建一个 jqPivot(此处的示例 jsFiddle:http://jsfiddle.net/reckert/vqetvqoc/1/) 我需要一个包含每个 X 维度的行,然后是值 - 我得到的是

我怎样才能删除上面折叠的行,这样我就可以得到更多类似的东西:

我已经尝试了 trirand jqGrid 和 free.jqGrid 并得到了相似的结果。 这是我正在使用的代码:

var mydata = [{
  "System": "Central Product Library (CPL)",
  "RFSTitle": "CPL - service support",
  "WorkRequest": "HBCBS00896187",
  "RFS": "40000",
  "PCR": "1",
  "EstimateType": "IE",
  "PHASE": "New",
  "Estimate": 10000.0,
  "BilledTo": null,
  "Lock": false,
  "CategoryID": 2,
  "Category": "BlueList",
  "Rate": 59.1600,
  "MonthEndDate": "2016-01-22T00:00:00",
  "MonthHours": 3750.000000000000,
  "MonthDollars": 221850.000000
}, {
  "System": "Central Product Library (CPL)",
  "RFSTitle": "CPL - service support",
  "WorkRequest": "HBCBS00896187",
  "RFS": "40000",
  "PCR": "1",
  "EstimateType": "IE",
  "PHASE": "New",
  "Estimate": 10000.0,
  "BilledTo": null,
  "Lock": false,
  "CategoryID": 2,
  "Category": "BlueList",
  "Rate": 59.1600,
  "MonthEndDate": "2016-02-26T00:00:00",
  "MonthHours": 6250.000000000000,
  "MonthDollars": 369750.000000
}, {
  "System": "Central Product Library (CPL)",
  "RFSTitle": "CPL - service support",
  "WorkRequest": "HBCBS00896187",
  "RFS": "40000",
  "PCR": "2",
  "EstimateType": "IE",
  "PHASE": "1",
  "Estimate": 2222.0,
  "BilledTo": null,
  "Lock": false,
  "CategoryID": 2,
  "Category": "BlueList",
  "Rate": 59.1600,
  "MonthEndDate": "2016-01-22T00:00:00",
  "MonthHours": 740.670000000000,
  "MonthDollars": 43817.850000
}, {
  "System": "Central Product Library (CPL)",
  "RFSTitle": "CPL - service support",
  "WorkRequest": "HBCBS00896187",
  "RFS": "40000",
  "PCR": "2",
  "EstimateType": "IE",
  "PHASE": "1",
  "Estimate": 2222.0,
  "BilledTo": null,
  "Lock": false,
  "CategoryID": 2,
  "Category": "BlueList",
  "Rate": 59.1600,
  "MonthEndDate": "2016-02-26T00:00:00",
  "MonthHours": 1234.450000000000,
  "MonthDollars": 73029.750000
}, {
  "System": "Central Product Library (CPL)",
  "RFSTitle": "CPL - service support",
  "WorkRequest": "HBCBS00896187",
  "RFS": "40000",
  "PCR": "2",
  "EstimateType": "IE",
  "PHASE": "1",
  "Estimate": 2222.0,
  "BilledTo": null,
  "Lock": false,
  "CategoryID": 2,
  "Category": "BlueList",
  "Rate": 59.1600,
  "MonthEndDate": "2016-03-25T00:00:00",
  "MonthHours": 246.890000000000,
  "MonthDollars": 14605.950000
}];


var grid = $("#grid");

grid.jqGrid('jqPivot',
  mydata, {
    xDimension: [

      {
        groupfield: false,
        groupSummary: false,
        width: 160,
        dataName: 'RFS',
        label: 'RFS'
      }, {
        isGroupField: false,
        groupSummary: false,
        width: 160,
        dataName: 'WorkRequest',
        label: 'WorkRequest'
      },

      {
        groupfield: false,
        groupSummary: false,
        width: 160,
        dataName: 'RFSTitle',
        label: 'Title'
      }, {
        groupfield: false,
        groupSummary: false,
        width: 160,
        dataName: 'Category',
        label: 'Category'
      }, {
        groupfield: false,
        groupSummary: false,
        width: 160,
        dataName: 'Phase',
        label: 'Phase'
      }, {
        groupfield: false,
        groupSummary: false,
        width: 160,
        dataName: 'Rate',
        label: 'Rate'
      },
    ],
    yDimension: [{
        dataName: 'MonthEndDate'
      }
      //,            { dataName: 'PCR' }
    ],
    aggregates: [{
      aggregator: 'sum',
      width: 160,
      member: 'MonthHours',
      label: "Hours"
    }, {
      aggregator: 'sum',
      width: 160,
      member: 'MonthDollars',
      label: "Dollars"
    }],
    groupSummary: false,
    colTotals: true
  },
  // grid options
  {
    groupingView: {
      hideFirstGroupCol: false,
      groupSummary: [false, false, false, false, false, false],
      groupSummaryPos: ["trailer", "trailer", "trailer", "trailer", "trailer", "trailer"],
    },
    pager: true,
    pager: "#MonthlyBillPivotPager",
    iconSet: "fontAwesome",
    cmTemplate: {
      autoResizable: true
    },
    shrinkToFit: false,
    autoresizeOnLoad: true,
    autoResizing: {
      compact: true
    },
    caption: 'RFS Billing',
    hideFirstGroupCol: false
  }
);

【问题讨论】:

    标签: jquery jqgrid jqpivot


    【解决方案1】:

    您的代码在某些属性或选项的值名称中存在小错误。例如,您使用包含不存在值的 groupSummaryPos"trailer",但唯一允许的值是:"header""footer"。我只删除了所有不需要的属性。我建议您阅读the wiki article,其中我描述了免费 jqGrid 中使用的jqPivot 的选项。

    您遇到的主要问题是数据分组问题。问题的原因是使用了错误的PHASE 属性名称。源数据包含该属性,但您使用了dataName: 'Phase'(大小写错误!!!):

    {
        groupfield: false,
        groupSummary: false,
        width: 160,
        dataName: 'Phase',
        label: 'Phase'
    }
    

    要解决此问题,您应该将xDimension 的项目更改为

    {
        width: 80,
        dataName: 'PHASE',
        label: 'Phase'
    }
    

    另外我删除了autoresizeOnLoad: true,因为它不使用顶级列标题中的文本。

    你可以在demo上看到分组的结果:https://jsfiddle.net/OlegKi/tcxv2o22/4/

    【讨论】:

    • 我希望也隐藏树,这样我的输出就会像我在上面发布的那样。我想我找到了一种方法,虽然我不知道它是否“最好”。
    • 我没有意识到我不能在 cmets 上按回车键 - 我更新的方法是添加 CSS 标签来隐藏我不想要的行:jsfiddle.net/reckert/vqetvqoc/3
    • @RobertEckert:我不明白你想要实现什么。在我看来,您只想没有分组。您可以使用 jqGrid 的grouping: false 选项。请参阅jsfiddle.net/tcxv2o22/5jsfiddle.net/tcxv2o22/7。此外,您应该清楚地了解 Free jqGrid、Guriddo jqGrid JS 和旧的 jqGrid 4.6.0 是不同的。我在免费的 jqGrid 中重写了 jqPivot 的完整实现。您不能混合来自不同 jqGrid 分叉的选项(请参阅您的演示)
    • @Oleg- 谢谢这些例子正是我想要的,在找到你的之前,我在原来的 jqGrid 和 Guriddo 之间徘徊,我刚刚发送了一笔捐款来弥补你刚刚节省的时间我:-)。
    • @RobertEckert:欢迎您并感谢您的捐赠!如果问题得到解决,您应该"accept" 回答。我尝试开发 jqGrid。 jqPivot 的代码我重写了完整的,只是为了保持与以前版本的兼容性。我这样做是因为修复旧版本错误的问题。我很高兴你喜欢它。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多