Ticket T1009944
Visible to All Users

Customize on runtime placed SummaryItem Sum in footer to ignore specific rows

created 4 years ago (modified 4 years ago)

Hi,

currently i have a TreeListView within a GridControl with a hierarchical logical data structure as ItemSource.
On placing a SummaryItem in runtime by an user to calculate the Sum on the column, the result ist erroneous because the fields in the sub structure are added too, see attached screen shots.

I tried to customize the sum in an SummaryItem which is placed by the user interface by an event handling to ignore the sub structure, which is already sumed in the parent, but the CustomSummaryEvent on TreeListView nor on GridControl is firering.
Obviously i missunderstood or missed a point in the event handling as described in your documentation.
Can you please give me a hint to the correct approach.

Answers approved by DevExpress Support

created 4 years ago

Hello Enis,

To achieve this goal, you can use the dxg:TreeListSummarySettings.IsRecursive attached property to determine whether a summary is calculated recursively i.e. including the child nodes. Set this attached property to false so that only the parent nodes are calculated for the summary, as shown below:

XAML
<dxg:GridControl.TotalSummary> <dxg:GridSummaryItem FieldName="Id" SummaryType="Sum" Alignment="Right" dxg:TreeListSummarySettings.IsRecursive="False"/> </dxg:GridControl.TotalSummary>

Please try this on your side and let us know the results.

Thanks,
Raphael

    Show previous comments (2)
    DevExpress Support Team 4 years ago

      Hello Enis,

      Thank you for the sample. In this case, you can handle the TotalSummary.CollectionChanged event of the GridControl and set the dxg:TreeListSummarySettings.IsRecursive attached property in the event handler, like so:

      C#
      public MainWindow() { InitializeComponent(); // ... gc.TotalSummary.CollectionChanged += TotalSummary_CollectionChanged; } private void TotalSummary_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { foreach (GridSummaryItem summary in sender as GridSummaryItemCollection) { if (summary.SummaryType == DevExpress.Data.SummaryItemType.Sum) { TreeListSummarySettings.SetIsRecursive(summary, false); } } gc.UpdateTotalSummary(); }

      In the code snippet above, you will notice that I called the UpdateTotalSummary method. This makes sure that the TotalSummary values are updated to reflect the changes. I've modified your sample to demonstrate this idea in action. Please try this on your side and let us know the results.

      Thanks,
      Raphael

      EN EN
      Enis Nalbant 1 4 years ago

        Hi,

        thank you.
        It works, so the primary requirement is achieved.

        But i'm still interested in the question, if it's possible to control the summary calculation similar to the GridControl custom summary event, to solve further requirement in the future.

        DevExpress Support Team 4 years ago

          Hello Enis,

          Thank you for the update. I am happy to hear that the issue is now resolved. As for your question regarding custom summary at runtime, our Runtime Summary Editor only has four built-in aggregate functions: Min, Max, Average, and Sum. Since the CustomSummary event is only fired when a SummaryItem's SummaryType is Custom, the event will not be fired when creating a summary item via the Runtime Summary Editor.

          If you would like to include custom options that uses the CustomSummary event, we've discussed a similar issue in How to add a user's options into Group Summary Editor. Please note that if the GridControl uses the TreeListView, use the TreeListView.CustomSummary event instead. Please try this on your side and let us know if you need further assistance.

          Thanks,
          Raphael

          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.