1 procedure SetcxGridColumnSum(Atbl: TDAMemDataTable; Agrid: TcxGridDBTableView);
2 var
3 csgItem: TcxDataSummaryItem;
4 i: Integer;
5 begin
6 //CXGRID统计功能
7 with Agrid do
8 begin
9 OptionsView.Footer := True;
10 OptionsView.GroupFooters := gfAlwaysVisible;
11 DataController.Summary.FooterSummaryItems.Clear;
12 with DataController.Summary do
13 begin
14 FooterSummaryItems.Clear;
15 BeginUpdate;
16 try
17 csgItem := FooterSummaryItems.Add;
18 csgItem.ItemLink := Agrid.Columns[0];
19 csgItem.Kind := skNone;
20 csgItem.Position := spFooter;
21 finally
22 EndUpdate;
23 end;
24 end;
25 with Atbl do
26 begin
27 for i := 0 to FieldCount - 1 do
28 begin
29 if (Fields[i].Visible) and((Fields[i].DataType = datfloat) or (Fields[i].DataType = datinteger)) then
30 begin
31 with DataController.Summary do
32 begin
33 BeginUpdate;
34 try
35 csgItem := FooterSummaryItems.Add;
36 csgItem.ItemLink := Columns[i + 2];
37 csgItem.Kind := skSum;
38 csgItem.Position := spFooter;
39 finally
40 EndUpdate;
41 end;
42 end;
43 end;
44 end;
45 end;
46 DataController.Summary.FooterSummaryValues[0] := '合计:'
47 end;
48 end;
2 var
3 csgItem: TcxDataSummaryItem;
4 i: Integer;
5 begin
6 //CXGRID统计功能
7 with Agrid do
8 begin
9 OptionsView.Footer := True;
10 OptionsView.GroupFooters := gfAlwaysVisible;
11 DataController.Summary.FooterSummaryItems.Clear;
12 with DataController.Summary do
13 begin
14 FooterSummaryItems.Clear;
15 BeginUpdate;
16 try
17 csgItem := FooterSummaryItems.Add;
18 csgItem.ItemLink := Agrid.Columns[0];
19 csgItem.Kind := skNone;
20 csgItem.Position := spFooter;
21 finally
22 EndUpdate;
23 end;
24 end;
25 with Atbl do
26 begin
27 for i := 0 to FieldCount - 1 do
28 begin
29 if (Fields[i].Visible) and((Fields[i].DataType = datfloat) or (Fields[i].DataType = datinteger)) then
30 begin
31 with DataController.Summary do
32 begin
33 BeginUpdate;
34 try
35 csgItem := FooterSummaryItems.Add;
36 csgItem.ItemLink := Columns[i + 2];
37 csgItem.Kind := skSum;
38 csgItem.Position := spFooter;
39 finally
40 EndUpdate;
41 end;
42 end;
43 end;
44 end;
45 end;
46 DataController.Summary.FooterSummaryValues[0] := '合计:'
47 end;
48 end;