如何显示在AngularJS UI网分组网格列脚注?

问题描述 投票:3回答:2

我使用AngularJS ui-grid跟着这个tutorial以显示网格的列脚注,它工作得很好。然而,我加入了网格分组功能之后,列页脚消失。

从105_footer教程中,我用这个来聚合列值:

aggregationType: uiGridConstants.aggregationTypes.SUM

在分组的列定义,我已将此添加到聚合列值:

treeAggregation: {type: uiGridGroupingConstants.aggregation.SUM}
css angularjs angularjs-directive angular-ui-grid
2个回答
3
投票

问题是,列聚集不知道分组的,因此它试图一味聚集在列中的所有可见行。这可能会导致错误的答案。

有两种形式的错在这里:

  1. 在年龄栏:“30最大”例如这样 - 默认分组把标签到文本。聚集那么不能聚集。你可以用customFinalizerFn解决这个问题,我在下面的plunker已经做了
  2. 聚集只是聚集的所有列,包括页眉行。所以,如果你有分组的一个水平,然后扩大所有,一个SUM聚集竟又双真正的价值。如果你有分组的两个级别这将是三倍。

总之,我认为这可能是一个坏主意,用柱页脚和列级聚集与分组。

http://plnkr.co/edit/1znbxELDzeNVK3x3G1c2?p=preview

showGridFooter: true,
showColumnFooter: true,

  { name: 'age', treeAggregationType: uiGridGroupingConstants.aggregation.MAX, aggregationType: uiGridConstants.aggregationTypes.avg, width: '20%', customTreeAggregationFinalizerFn: function( aggregation ){ aggregation.rendered = aggregation.value; } },

0
投票

作为PaulLanswer说,问题就出现了如柱聚集和分组导致问题彼此。

这里最好的办法是删除列聚集。如果您正在使用分组,例如SUM它会自动显示在页脚的SUM列聚集。我不明白,需要使用一个单独的列聚集。

您可以在此Plunker看到这一点:

{
  name: 'age',
  treeAggregationType: uiGridGroupingConstants.aggregation.MAX,
  width: '20%',
}

注意:您甚至不需要,如果你不使用的列聚合使用customTreeAggregationFinalizerFn。 (但你会需要它,如果使用细胞过滤器)

© www.soinside.com 2019 - 2024. All rights reserved.