8th May 2015

DevExpress XAF – Add a List View Group Footer

DevExpress XAF – Add a List View Group Footer

Scenario

DevExpress by default gives you the functionality within the Model to group list views together based on a selected field and show a count of records within the Group Header as seen in the screenshot below.

A user can then expand each group to see each individual record. To give the user a better understanding and overview of the records we wish to add a group footer to each group and display a total of the Time In Days spent against each group.

Solution

Within the Module.Win project create a new blank View Controller and customise the code below as required within it to get the results you require.

/// <summary>
/// Called when [view controls created].
/// </summary>
protected override void OnViewControlsCreated()

base.OnViewControlsCreated(); if (View.Id == "MyListView")

GridControl grid = (GridControl)View.Control; GridView view = (GridView)grid.FocusedView; view.Columns.View.OptionsSelection.MultiSelect = true; view.OptionsSelection.MultiSelectMode = GridMultiSelectMode.CellSelect; view.OptionsView.GroupFooterShowMode = GroupFooterShowMode.VisibleAlways; GridColumn timeValueColumn = view.Columns["TimeInDays"]; GridGroupSummaryItem timeValueSummaryItem = new GridGroupSummaryItem(); timeValueSummaryItem.FieldName = "TimeInDays"; timeValueSummaryItem.SummaryType = SummaryItemType.Sum; timeValueSummaryItem.DisplayFormat = "Personnel Total (Days) =

0:n2

"; timeValueSummaryItem.Tag = 1; timeValueSummaryItem.ShowInGroupColumnFooter = timeValueColumn; view.GroupSummary.Add(timeValueSummaryItem);


Implementing the above code creates a group footer against each group and displays a count of the Time In Days of each record within the group.

Fill in this quick form and discover your digital future
Choose your interests:

Where to find us

We'd love to welcome you into our office! We're only 20 miles north of Peterborough, conveniently just off the A16.

Carver House
Apex Court, Elsoms Way
Pinchbeck
Lincolnshire
PE11 3UL