在动态添加Footer SummaryItem和Group的Item

http://www.delphibbs.com/delphibbs/dispq.asp?lid=2135268


with tvOrders.DataController.Summary do
  begin
    BeginUpdate;
    try
      with FooterSummaryItems.Add as TcxGridDBTableSummaryItem do
      begin
        Column := tvOrdersPaymentAmount;
        Kind := skSum;
        Format := 'SUM = $,0.00;-$,0.00';
      end;
    finally
      EndUpdate;
    end;
    //Update all open details of the master view (tvCars)
    tvCars.DataController.ClearDetails;
  end;
//
以上是TcxGridDBTableSummaryItem
但是我在tcxgriddbbandedtableview 中没有反应不显示??
、、、、、、、、、、、、、、、、、、
with tvOrders.DataController.Summary do
  begin
    BeginUpdate;
    try
      SummaryGroups.Clear;
      //The first summary group
      with SummaryGroups.Add do
      begin
        //Add proposed grouping column(s)
        TcxGridTableSummaryGroupItemLink(Links.Add).Column := tvOrdersCustomerID;
        //Add summary items
        with SummaryItems.Add as TcxGridDBTableSummaryItem do
        begin
          Column := tvOrdersPaymentAmount;
          Kind := skSum;
          Format := 'Amount Paid: $,0';
        end;
        with SummaryItems.Add as TcxGridDBTableSummaryItem do
        begin
          Column := tvOrdersPaymentAmount;
          Kind := skCount;
          Format := 'Records: 0';
        end;
      end;
      //The second summary group
      with SummaryGroups.Add do
      begin
        //Add proposed grouping column(s)
        TcxGridTableSummaryGroupItemLink(Links.Add).Column := tvOrdersProductID;
        //Add summary items
        with SummaryItems.Add as TcxGridDBTableSummaryItem do
        begin
          Column := tvOrdersQuantity;
          Kind := skSum;
          Position := spFooter;
          Format := 'TOTAL = 0';
        end;
        with SummaryItems.Add as TcxGridDBTableSummaryItem do
        begin
          Column := tvOrdersPurchaseDate;
          Kind := skMin;
          Position := spFooter;
        end;
      end;
    finally
      EndUpdate;
    end;
  end;
、、、、、、、、、、、、、、、、、、、、、、、、、
group的也一样!
根据如下创建的字段 没有名字
With cxgrid1dbbandedtableview1.CreateColumn do
    begin
     Caption :='月%';
     DataBinding.FieldName:='zpmp' ;
     Position.BandIndex := 4;
     Position.RowIndex := 0;
     //Position.LineCount:=1;
     Visible := True;
showmessage(cxgrid1dbbandedtableview1.CreateColumn.Name);、、、
      end;
从而引起了以上的错误,我想,不知道有没有高手帮忙


从帮助中看到两个例子:、、
、、、、、、、、、、、、、、
procedure TForm1.cxGrid1DBTableView1TcxGridDBDataControllerTcxDataSummary
DefaultGroupSummaryItemsSummary(
  ASender: TcxDataSummaryItems; Arguments: TcxSummaryEventArguments;
  var OutArguments: TcxSummaryEventOutArguments);
begin
  if (VarIsNull(OutArguments.Value)) then
    OutArguments.Done := True;
end;
/
//Delphi
procedure TForm1.cxGrid1DBTableView1TcxGridDBDataControllerTcxDataSummary
DefaultGroupSummaryItemsSummary(
  ASender: TcxDataSummaryItems; Arguments: TcxSummaryEventArguments;
  var OutArguments: TcxSummaryEventOutArguments);
var
  AArea, APopulation: Extended;
begin
  //Locate a value in the specific record for Area item
  AArea := ASender.DataController.Values[Arguments.RecordIndex, DBTableView1Area.Index];
  //Locate a value in the specific record for Population item
  APopulation := ASender.DataController.Values[Arguments.RecordIndex, DBTableView1Population.Index];
  //Set population density to Value
  OutArguments.Value := APopulation / AArea;
end;
不知道如何取得另一字段的foooter 和更改这一字段的footer 


发现一个example
、、、、、、、、、、、、、、、、、、、
In this example, a summary value is calculated based on the results of other two summaries.  The TcxDataSummary.OnAfterSummary event, which occurs when all summaries are already calculated, is used to calculate a new summary.
Let us examine a table that represents information from the pricelist containing three columns: VendorNo, Description, ListPrice.  We want to group data by vendor and calculate three summaries: the summary that displays a sum of the ListPrice column values, the summary representing the number of goods supplied by a specific vendor and the summary that displays the average value of the ListPrice column values.  Though it is possible to create an average summary by specifying its skAverage type, we will calculate it based on two other summary values and format it in a specific manner.  
The Initialize procedure groups data by vendor and creates three summaries.  The third summary is of the skNone type.  It is substituted for the average summary in MyAfterSummary (the OnAfterSummary event handler).
//Delphi
procedure TForm1.Initialize;
var
  ASummaryItem: TcxDataSummaryItem;
begin
  //group by vendor
  DBTableView1VendorNo.GroupIndex := 0;
  DBTableView1VendorNo.Visible := False;
  with DBTableView1.DataController.Summary do
  begin
    BeginUpdate;
    try
      //set prefix and postfix for a group capion
      DefaultGroupSummaryItems.BeginText := '{';
      DefaultGroupSummaryItems.EndText := '}';
      //summary on ListPrice
      ASummaryItem := DefaultGroupSummaryItems.Add;
      ASummaryItem.Kind := skSum;
      ASummaryItem.ItemLink := DBTableView1ListPrice;
      ASummaryItem.Position := spFooter;
      //summary on Description
      ASummaryItem := DefaultGroupSummaryItems.Add;
      ASummaryItem.Kind := skCount;
      ASummaryItem.ItemLink := DBTableView1Description;
      ASummaryItem.Position := spFooter;
      //dummy summary on Description
      ASummaryItem := DefaultGroupSummaryItems.Add;
      ASummaryItem.Kind := skNone;
      ASummaryItem.ItemLink := DBTableView1Description;
      //subscribe to the OnAfterSummary event
      OnAfterSummary := MyAfterSummary;
    finally
      EndUpdate;
    end;
  end;
end;
procedure TForm1.MyAfterSummary(ASender: TcxDataSummary);
var
  AChildDataGroupsCount: Integer;
  AChildDataGroupIndex, AParentDataGroupIndex: TcxDataGroupIndex;
  AChildPosition: Integer;
begin
  //iterate through data groups at the level 0
  AParentDataGroupIndex := -1;
  with DBTableView1.DataController.Groups do
  begin
    AChildDataGroupsCount := ChildCount[AParentDataGroupIndex];
    for AChildPosition := 0 to AChildDataGroupsCount - 1 do
    begin
      //data group index of a child
      AChildDataGroupIndex := ChildDataGroupIndex[AParentDataGroupIndex, AChildPosition];
      CalculateGroupAverage(AChildDataGroupIndex);
    end;
  end;
end;
procedure TForm1.CalculateGroupAverage(ADataGroupIndex: TcxDataGroupIndex);
var
  AVarSum, AVarCount, AVarAverage: Variant;
begin
  with DBTableView1.DataController.Summary do
  begin
    //get sum of prices for specific data group
    //the second argument identifies a summary index in the
    //TcxDataSummary.DefaultGroupSummaryItems collection
    AVarSum := GroupSummaryValues[ADataGroupIndex, 0];
    //get records count in a group
    AVarCount := GroupSummaryValues[ADataGroupIndex, 1];
    if not (VarIsNull(AVarSum) or VarIsNull(AVarCount)) then
    begin
      AVarAverage := AVarSum / AVarCount;
      GroupSummaryValues[ADataGroupIndex, 2] := Format('%m / %d = %m', [Double(AVarSum), Integer(AVarCount), Double(AVarAverage)]);
    end;
  end;
end;

转载于:https://www.cnblogs.com/railgunman/archive/2011/01/02/1924110.html

相关推荐

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
©️2022 CSDN 皮肤主题:编程工作室 设计师:CSDN官方博客 返回首页
评论
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值