Step 4: Display Summaries
- 2 minutes to read
In This Article
This step describes how to display summaries:
- Process summaries in the virtual source.
- Display summaries in the GridControl.
#Summary Types
The Issues Service allows you to obtain:
- The total count of rows.
- The last created object’s datetime.
public class IssuesSummaries {
public int Count { get; private set; }
public DateTime? LastCreated { get; private set; }
}
#Display Summaries
Process summaries in the virtual source:
- Create a task that uses the Issues Service’s GetSummariesAsync method to get summaries from the data source.
- Use the Summaries property to get the GridControl‘s summary items.
- Handle the InfiniteAsyncSource.GetTotalSummaries event.
- Get a list of data source summaries that correspond to the GridControl‘s summary items. Assign the list to the Result property.
public MainPage() { // ... source.GetTotalSummaries += (o, e) => { e.Result = GetTotalSummariesAsync(e); }; } static async Task<object[]> GetTotalSummariesAsync(GetSummariesAsyncEventArgs e) { IssueFilter filter = MakeIssueFilter(e.Filter); var summaryValues = await IssuesService.GetSummariesAsync(filter); return e.Summaries.Select(x => { if (x.SummaryType == SummaryType.Count) return (object)summaryValues.Count; if (x.SummaryType == SummaryType.Max && x.PropertyName == "Created") return summaryValues.LastCreated; throw new InvalidOperationException(); }).ToArray(); }
Set the DataControlBase.ShowFixedTotalSummary property to true to show the Fixed Summary Panel. You can also use the DataControlBase.ShowTotalSummary property to display the Summary Panel.
<dxg:GridControl ... ShowFixedTotalSummary="True"> <!-- ... --> </dxg:GridControl>
Specify the GridControl.TotalSummary property to display total summaries in the GridControl:
<dxg:GridControl.TotalSummary> <dxg:GridTotalSummaryItem SummaryType="Count" Alignment="Right"/> <dxg:GridTotalSummaryItem SummaryType="Max" FieldName="Created" Caption="Last created:" Alignment="Right"/> </dxg:GridControl.TotalSummary>
#Continue or Review
- Proceed to Virtual Sources Limitations.
- Review Step 3 - Enable Filter Operations.