Ticket T955946
Visible to All Users

Blazor - How to show total summaries in the grid control

created 4 years ago

Hi,

I create a XAF Blazor Solution with wizard.
I create an XpObject, at the Model designer on XPObject_ListView set the IsFooterVisible to true and add summary(sum) to a decimal column.
But i cannot see the totals when application is running. Is there anything else that i have to do?

Thx
Spyros

Answers approved by DevExpress Support

created 4 years ago (modified 2 years ago)

Hi Spyros,

v20.2.6+

With v20.2.6, you can configure total summaries in the Model Editor (as in WinForms or WebForms). To display the footer, set the IModelListView.IsFooterVisible property to True in the Model Editor.
Clipboard-File-2.png

Older versions

Our Blazor DataGrid supported total summaries in v20.2. At the moment, we don't have built-in integration for total summaries in XAF Blazor. To show total summaries in XAF Blazor, create a controller that will set the TotalSummary property of the DataGrid Model:

BlazorFooterViewController.cs

C#
using DevExpress.ExpressApp; using DevExpress.ExpressApp.Blazor.Editors.Grid; namespace MySolution.Module.Blazor.Controllers { public class BlazorFooterViewController : ViewController<ListView> { protected override void OnViewControlsCreated() { base.OnViewControlsCreated(); if (View.Model.IsFooterVisible && View.Editor is GridListEditor gridListEditor) { IDxDataGridAdapter dataGridAdapter = gridListEditor.GetDataGridAdapter(); dataGridAdapter.DataGridModel.TotalSummary = DataGridFooterSummary.Create(View.Model.Columns); } } } }

Then, create a Razor component that will render DxDataGridSummaryItems:

DataGridFooterSummary.razor

Razor
@using DevExpress.Blazor @using DevExpress.ExpressApp.Model @foreach (IModelColumn modelColumn in ModelColumns) { foreach (DevExpress.ExpressApp.Model.IModelColumnSummaryItem summary in modelColumn.Summary) { if (summary.SummaryType != SummaryType.None) { <DxDataGridSummaryItem DisplayFormat=@modelColumn.DisplayFormat Field=@modelColumn.ModelMember.MemberInfo.BindingName SummaryType=@ConvertSummaryItemType(summary.SummaryType) /> } } } @code { [Parameter] public IModelColumns ModelColumns { get; set; } public static RenderFragment Create(IModelColumns modelColumns) => @<DataGridFooterSummary ModelColumns=modelColumns />; private SummaryItemType ConvertSummaryItemType(DevExpress.ExpressApp.Model.SummaryType summaryItemType) { return summaryItemType switch { DevExpress.ExpressApp.Model.SummaryType.Sum => SummaryItemType.Sum, DevExpress.ExpressApp.Model.SummaryType.Average => SummaryItemType.Avg, DevExpress.ExpressApp.Model.SummaryType.Count => SummaryItemType.Count, DevExpress.ExpressApp.Model.SummaryType.Custom => throw new NotSupportedException(), DevExpress.ExpressApp.Model.SummaryType.Max => SummaryItemType.Max, DevExpress.ExpressApp.Model.SummaryType.Min => SummaryItemType.Min, DevExpress.ExpressApp.Model.SummaryType.None => SummaryItemType.None, _ => SummaryItemType.None }; } }

I attached a sample project to illustrate my idea.

P.S. Would you mind making this ticket public so that it is available to other customers?

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

      My pleasure, Spyros!

      Dennis Garavsky (DevExpress) 4 years ago

        With v20.2.6, you can configure total summaries in the Model Editor (as in WinForms or WebForms).
        Clipboard-File-2.png

        Dennis Garavsky (DevExpress) 4 years ago

          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.