Delphi 如何在数据透视网格中显示运行总计?
我需要在DevXPress数据透视网格中显示总计,如总计加上最后一个总计。Delphi 如何在数据透视网格中显示运行总计?,delphi,grid,devexpress,Delphi,Grid,Devexpress,我需要在DevXPress数据透视网格中显示总计,如总计加上最后一个总计。 示例: 取此值: 三月:25日 四月:10日 五月三十日 因此: March April May 25 35 65 如何将我的数据透视网格配置为此 提前感谢。您应该将字段的属性设置为true。您需要在字段的OnCalculateCustomSummary事件中添加以下代码: procedure TMyForm.cxDBPivotGrid1Field2CalculateCustomSummary(
示例:
取此值: 三月:25日
四月:10日
五月三十日 因此:
March April May
25 35 65
如何将我的数据透视网格配置为此
提前感谢。您应该将字段的属性设置为true。您需要在字段的OnCalculateCustomSummary事件中添加以下代码:
procedure TMyForm.cxDBPivotGrid1Field2CalculateCustomSummary(Sender: TcxPivotGridField; ASummary: TcxPivotGridCrossCellSummary);
var
AColumn: TcxPivotGridGroupItem;
APrevCrossCell: TcxPivotGridCrossCell;
APrevCrossCellSummary: TcxPivotGridCrossCellSummary;
begin
inherited;
AColumn := ASummary.Owner.Column;
if (AColumn.Level = -1) then
// column grand totals
ASummary.Custom := ASummary.Sum
else begin
// all cells, except for column grand totals
// getting a custom summary calculated for the previous grouping value
if AColumn.PrevSibling <> nil then begin
APrevCrossCell := AColumn.PrevSibling.GetCellByCrossItem(ASummary.Owner.Row);
APrevCrossCellSummary := APrevCrossCell.SummaryCells[Sender.SummaryIndex];
ASummary.Custom := VarToDouble(APrevCrossCellSummary.Custom) + VarToDouble(ASummary.Sum);
end
else
ASummary.Custom := ASummary.Sum;
end;
end;
摘自:
好的,但是我有一个比它更早的版本,它有这个属性,那么我需要手动实现这个函数。
procedure TForm1.cxDBPivotGrid1Field2GetDisplayText(Sender: TcxPivotGridField; ACell: TcxPivotGridDataCellViewInfo; var AText: string);
begin
inherited;
AText := VarToStr(ACell.CellSummary.Custom)
end;