Ticket T1284214
Visible to All Users

DataController.Summary.FooterSummaryItems how to tell Footer from GroupFooter?

created 5 days ago

Hello,

  1. I want to do different calculations depending on the footer vs GroupFooter type of summary but within the event method, I don't know how to tell the difference. I can play with the tags but I'd prefer to be able to identify the type of summary.

  2. More problematic: I have used this article to hide one of the groupfooters. This is working correctly (at the price of a bigger complexity) but I am not able to do custom calculations.

As a reminder, on that article, we create a subclass of TcxDBBandedTableView (and a few other classes) and do something like this in the OnCreate event of the form:

Delphi
AView := GRoyalties.CreateView(TcxMyGridDBBandedTableView) as TcxMyGridDBBandedTableView; AView.AssignPattern(vRoyalties); GRoyaltiesLevel2.GridView := AView;

My custom calculation code is this:

Delphi
procedure TFAgreement.vRoyaltiesDataControllerSummaryFooterSummaryItemsSummary( ASender: TcxDataSummaryItems; Arguments: TcxSummaryEventArguments; var OutArguments: TcxSummaryEventOutArguments); var AValue,BaseRedev: Variant; IsSelected: Variant; AItem: TcxGridTableSummaryItem; avirer:String; begin AItem := TcxGridTableSummaryItem(Arguments.SummaryItem); if (AItem.Tag > 0) and (AItem.Position = spFooter) then begin avirer:=TcxGridDBBandedColumn(aitem.Column).DataBinding.FieldName; if avirer='s' then write; AValue := TcxGridDBBandedTableView(GRoyalties.FocusedView).DataController.Values[ Arguments.RecordIndex, AItem.Column.Index ]; BaseRedev := TcxGridDBBandedTableView(GRoyalties.FocusedView).DataController.Values[ Arguments.RecordIndex, TcxGridDBBandedTableView(GRoyalties.FocusedView).GetColumnByFieldName('baseredevance').Index ]; if not VarIsNull(AValue) and not VarIsNull(BaseRedev) then OutArguments.Value:=AValue*BaseRedev/100 else OutArguments.Value:=0; OutArguments.value:=18; end end;

The AItem.tag for this particular GroupFooter summary is 2

The avirer variable is here for debugging purposes and always contains "idad" which is a field that is not used in any summary. So my guess is that the Arguments.SummaryItem points to something wrong.
As you can see, I am assigning the value 18 to OutArguments.value but I never see this value in any Summary although the program correctly stops on the breakpoint that I set on the line if avirer='s' then.

I hope you can help me understand what is going on.
Thanks in advance.

Answers approved by DevExpress Support

created 4 days ago

Hello,

Thank you for the details.

Basically, you can use the following API members to determine a column and the current summary item's position:

Delphi
procedure TForm2.tvSampleDataControllerSummaryDefaultGroupSummaryItemsSummary( ASender: TcxDataSummaryItems; Arguments: TcxSummaryEventArguments; var OutArguments: TcxSummaryEventOutArguments); begin //use Arguments.SummaryItem.ItemLink.ClassName to check the real class name //e.g. TcxGridDBBandedColumn Memo1.Lines.Add(TcxGridDBColumn(Arguments.SummaryItem.ItemLink).Name); if Arguments.SummaryItem.Position = spGroup then Memo1.Lines.Add('Group') else Memo1.Lines.Add('Footer'); end;

Since the event is handled at the DefaultGroupSummaryItems level, all items are at the groups level.

If you wish to use a single handler for DefaultGroupSummaryItems and FooterSummaryItems, you can create a separate function, e,g.:

Delphi
procedure TForm2.DoSummary(ASender: TcxDataSummaryItems; Arguments: TcxSummaryEventArguments; var OutArguments: TcxSummaryEventOutArguments; IsGroup: Boolean); begin //custom calculations end; procedure TForm2.tvSampleDataControllerSummaryDefaultGroupSummaryItemsSummary( ASender: TcxDataSummaryItems; Arguments: TcxSummaryEventArguments; var OutArguments: TcxSummaryEventOutArguments); begin DoSummary(ASender, Arguments, OutArguments, True); end; procedure TForm2.tvSampleDataControllerSummaryFooterSummaryItemsSummary( ASender: TcxDataSummaryItems; Arguments: TcxSummaryEventArguments; var OutArguments: TcxSummaryEventOutArguments); begin DoSummary(ASender, Arguments, OutArguments, False); end;

If you still encounter issues, please illustrate your current implementation in a deployable project that uses our TdxMemData as a dataset. We will look for a more precise solution.

    Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

    Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.