Quantcast
Channel: Developer Express Inc.
Viewing all articles
Browse latest Browse all 2370

WPF Data Grid and TreeList – Summaries for Selected Records (v19.2)

$
0
0

If your end-users are like most, they need to perform specific operations against selected Data Grid / TreeList records. If your app necessitates such functionality, you may need to provide additional information to your end-users to improve the app’s overall user experience. For example, you may wish to display the total number of selected items or calculate a specific total for records selected within the Data Grid / TreeList.

Prior to v19.2, our WPF Data Grid and TreeList required use of Custom Summaries to address this use case. Our newest version addresses this limitation and allows you to compute summaries against selected records with absolute ease. Your users can now select records and immediately obtain summary values within the Data Grid / TreeList summary footer.

To better explain the power of this new features, let’s quickly consider two usage scenarios:

Selected Items: Count

The TreeList below displays a list of employees.

Goal: Calculate the total count of selected employee records.

You can compute the selected record count with the SummaryItemBase.CalculationMode property. In default mode, our Data Grid and TreeList controls calculate summaries against all rows. To calculate a summary against selected rows, set the SummaryItemBase.CalculationMode property to SelectedRows:

<dxg:TreeListControl SelectionMode="Row">
    <dxg:TreeListControl.TotalSummary>
        <dxg:TreeListSummaryItem FieldName="FullName" 
                                 SummaryType="Count" 
                                 DisplayFormat="Selected Count={0}" 
                                 Alignment="Left" 
                                 CalculationMode="SelectedRows" />
        <dxg:TreeListSummaryItem FieldName="FullName" 
                                 SummaryType="Count" 
                                 DisplayFormat="Total Count={0}" 
                                 Alignment="Right" />
    </dxg:TreeListControl.TotalSummary>
    <dxg:TreeListControl.View>
        <dxg:TreeListView x:Name="view" />
    </dxg:TreeListControl.View>
</dxg:TreeListControl>

Demo: TreeList - Multiple Node Selection

Selected Rows: Sum

The following screenshot contains a list of product orders.

Goal: Calculate the total purchase price of selected products when at least two products are selected (when no product or only a single product is selected, cost summary will not be computed).

If you set the SummaryItemBase.CalculationMode property to Mixed, our WPF Data Grid will calculate summary by selected rows when count exceeds one; otherwise, it calculates summaries against all rows:

<dxg:GridControl x:Name="grid" SelectionMode="Row">
    <dxg:GridControl.View>
        <dxg:TableView SummaryCalculationMode="Mixed"
                       ShowTotalSummary="True" />
    </dxg:GridControl.View>
    <dxg:GridControl.TotalSummary>
        <dxg:GridSummaryItem FieldName="Total" SummaryType="Sum" />
    </dxg:GridControl.TotalSummary>
    <dxg:GridControl.GroupSummary>
        <dxg:GridSummaryItem FieldName="Total" SummaryType="Sum" />
    </dxg:GridControl.GroupSummary>
</dxg:GridControl>

The DataViewBase.SummaryCalculationMode property allows you to specify the calculation mode used for all summaries within the grid’s view.

Demo: Data Grid - Web Style Row Selection

Your Thoughts Count

Please let us know what you think about the new feature, or if you have any additional requests related to it.


Viewing all articles
Browse latest Browse all 2370

Trending Articles