PivotGridField.SortByConditions Property
Contains conditions that identify the column or row whose values are sorted.
Namespace: DevExpress.Xpf.PivotGrid
Assembly: DevExpress.Xpf.PivotGrid.v24.2.dll
NuGet Package: DevExpress.Wpf.PivotGrid
Declaration
Property Value
Type | Description |
---|---|
SortByConditionCollection | The collection whose items identify the column or row of values to be sorted. |
Remarks
To sort data by summaries, do the following:
- Use the PivotGridField.SortByField or PivotGridField.SortByFieldName property to specify a field (typically a data field) against which summary values should be calculated. If the PivotGridField.SortByField property is used, the summary type is specified by this field’s PivotGridField.SummaryType property. If the PivotGridField.SortByFieldName property is used, the required summary type should be specified using the PivotGridField.SortBySummaryType property.
- To sort data according to an individual column or row, you need to specify the column or row via the
PivotGridField.SortByConditions
collection. Do this by adding items to this collection, each of which identifies a specific field and its value. If thePivotGridField.SortByConditions
collection is empty, the current field values are sorted by grand total values.
To learn more, see Sorting by Summary.
Example
The following example demonstrates how to sort data by a particular column.
In this example, values of the Product Name field are sorted by September 1994 column summary values. To do this, two sort conditions represented by SortByCondition instances are created. One of them identifies the ‘1994’ field value, while another identifies the ‘September’ value. These sort conditions are added to the Product Name field’s PivotGridField.SortByConditions
collection to specify the column by which Product Name values should be sorted. A data field that identifies the column is specified via the PivotGridField.SortByField property.
using System.Windows;
using DevExpress.Xpf.PivotGrid;
namespace DXPivotGrid_SortBySummary {
public partial class MainWindow : Window {
public MainWindow() {
InitializeComponent();
pivotGridControl1.DataSource =
(new nwindDataSetTableAdapters.SalesPersonTableAdapter()).GetData();
}
private void pivotGridControl1_Loaded(object sender, RoutedEventArgs e) {
// Locks the pivot grid from updating while the Sort by Summary
// settings are being customized.
pivotGridControl1.BeginUpdate();
try {
// Specifies a data field whose summary values should be used to sort values
// of the Product Name field.
fieldProductName.SortByField = fieldUnitPrice;
// Specifies a column by which the Product Name field values should be sorted.
fieldProductName.SortByConditions.Add(new SortByCondition(fieldYear, "1994"));
fieldProductName.SortByConditions.Add(new SortByCondition(fieldMonth, "9"));
}
finally {
// Unlocks the pivot grid and applies changes.
pivotGridControl1.EndUpdate();
}
}
}
}