cxgrid中,如何根据列名或字段名取得footer值
注意,不是根据index取得footer值
cxgrdtbv1.DataController.Summary.FooterSummaryValues[0];
------解决方案--------------------------------------------------------
- Delphi(Pascal) code
with cxGrid1DBTableView1.DataController.Summary do FooterSummaryValues[FooterSummaryItems.IndexOfItemLink( cxGrid1DBTableView1.GetColumnByFieldName('字段名'))];
cxgrid动态生成footersummary 并获得值
var f: TcxGridDBTableSummaryItem;
cx_for_mctv.OptionsView.Footer := true;
//cxGrid1DBTableView1.OptionsView.Footer := True;
f := (cx_for_mctv.DataController.Summary.FooterSummaryItems.Add) as TcxGridDBTableSummaryItem;
f.FieldName := cx_for_mctv.Columns[2].DataBinding.FieldName;
f.Column := cx_for_mctv.Columns[2];
f.Kind := skSum;
///////////////////////////////////////////////////////////////////
procedure Tform_for_cz.CreateSumFooter(cxTableView: TcxGridDBTableView;
const fieldList: string);
var
i: Integer;
f: TcxGridDBTableSummaryItem;
l: TStringList;
begin
l := TStringList.Create;
l.DelimitedText := fieldList;
l.Delimiter := ',';
cxTableView.OptionsView.Footer := True;
for i := 0 to cxTableView.ColumnCount - 1 do
begin
if l.IndexOf(cxTableView.Columns[i].DataBinding.FieldName) <> -1 then
begin
f := (cxTableView.DataController.Summary.FooterSummaryItems.Add) as TcxGridDBTableSummaryItem;
f.FieldName := cxTableView.Columns[i].DataBinding.FieldName;
f.Column := cxTableView.Columns[i];
if f.FieldName <> '凭证号' then
f.Kind := skSum
else
f.kind := skcount;
end;
end;
l.Free;
end;
View_Client.DataController.Summary.FooterSummaryValues[0],//得到值 |