问题描述
在我的 ASPxGridView
中,
我总是简单地得到 IPOTEK
列中的该代码;
I getting total simply IPOTEK
column in footer with this code;
<TotalSummary>
<dx:ASPxSummaryItem FieldName="IPOTEK" SummaryType="SUM" ShowInGroupFooterColumn="IPOTEK" DisplayFormat="n0" />
</TotalSummary>
我的平均值 IPOTEK
列当我在Group的页脚中进行分组时。
And i getting average value of IPOTEK
column when i grouping in Group's footer.
<GroupSummary>
<dx:ASPxSummaryItem FieldName="IPOTEK" SummaryType="AVERAGE" ShowInGroupFooterColumn="IPOTEK" DisplayFormat="n0" />
</GroupSummary>
一切都OK。例如当我分组,它看起来像这样; ( IPOTEK
列开始 109.827 )
Everything is OK. For example when i grouping with, it looks like this; (IPOTEK
column is starting 109.827)
我想要的是;在 TotalSummary
中,只有 IPOTEK
列的 GroupSummary
。
What i want is; in TotalSummary
, only total of GroupSummary
values for IPOTEK
column.
现在,对于此数据添加 TotalSummary
值 109.827
* 3
= 329.481
(GroupSummary * 3)
Rigth now, for this data adding TotalSummary
value 109.827
* 3
= 329.481
(GroupSummary * 3)
我想要的是,只有这个数据只能添加,而且只有 GropupSummary
的值为 TotalSummary
。
What i want, for this data adding only and only GropupSummary
value to TotalSummary
.
我该怎么做?
最好的问候,Soner
Best Regards, Soner
推荐答案
嗯,没有直接解决这个任务。我看到两种选择:
Well, there is no a straightforward solution to this task. I see two alternatives:
1)使用的页脚摘要和DevExpress.Data.CustomSummaryProcess.Finalize的阶段尝试运行所有组行,获取相应的摘要值并对它们进行求和。要运行组行,请使用以下代码:
1) use a custom summary for the footer summary and at the stage of the DevExpress.Data.CustomSummaryProcess.Finalize try to run through all group rows, obtain the corresponding summary values and sum them. To run through group rows, use the following code:
protected void ASPxGridView1_CustomSummaryCalculate(object sender, DevExpress.Data.CustomSummaryEventArgs e) {
if(e.SummaryProcess == DevExpress.Data.CustomSummaryProcess.Finalize) {
ASPxGridView grid = sender as ASPxGridView;
double total = 0;
for(int i = 0; i < grid.VisibleRowCount; i++)
if(grid.IsGroupRow(i))
total += Convert.ToDouble(grid.GetGroupSummaryValue(i, grid.GroupSummary[0]));
e.TotalValue = total;
e.TotalValueReady = true;
}
}
2)在列的FooterTemplate容器中使用标签,处理GridView的PreRender和以设置此标签值。该值应该使用上面的代码计算。
2) use a label within the column's FooterTemplate container and handle the GridView's PreRender and BeforeGetCallbackResult to set this label value. The value should be calculated using the code above.
我希望这有助于。
更新
为什么要使用这段代码:
why are using this code:
if (grid.IsGroupRow(7))
7是一个visibleRowIndex,你应该传递i参数
7 is a visibleRowIndex, you should pass the i parameter there
这篇关于DevExpress中GroupSummary到TotalSummary的总和的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!