PivotGridControl.GetFieldValueOLAPMember(PivotGridField, Int32) Method
Returns an OLAP member for the specified field value.
Namespace: DevExpress.XtraPivotGrid
Assembly: DevExpress.XtraPivotGrid.v24.1.dll
NuGet Package: DevExpress.Win.PivotGrid
Declaration
Parameters
Name | Type | Description |
---|---|---|
field | PivotGridField | A PivotGridField object that represents the Pivot Grid Control field. |
lastLevelIndex | Int32 | An integer value that specifies the cell’s index. |
Returns
Type | Description |
---|---|
IOLAPMember | An object that implements the IOLAPMember interface. null (Nothing) if the specified summary cell doesn’t correspond to the specified field’s value. |
Remarks
If the field parameter specifies the row field, the lastLevelIndex parameter specifies the summary cell’s vertical position (within a column). If the field parameter specifies the column field, the lastLevelIndex parameter specifies the summary cell’s horizontal position (within a row).
Example
The following example demonstrates how to implement sorting by summary in OLAP mode. In this example, values of the Fiscal Year field are sorted by the Australia | Bendigo column summary values.
Two PivotGridFieldSortCondition objects contain OLAP members that correspond to Australia and Bendigo values. The PivotGridControl.GetFieldValueOLAPMember
method obtains these values. Obtained values specify columns by which the Fiscal Year field should be sorted and are stored in the Fiscal Year’s PivotGridFieldSortBySummaryInfo.Conditions collection. OLAP members can be obtained only for visible field values. For this reason, the Australia field value is expanded before initializing OLAP members to obtain the Bendigo member. The PivotGridFieldSortBySummaryInfo.Field property specifies the data field whose summary values should be used to sort values of the Fiscal Year field.
This sample uses the Adventure Works 2008 cube.
using System;
using System.Windows.Forms;
using DevExpress.XtraPivotGrid;
namespace XtraPivotGrid_OLAPSortBySummary {
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e) {
// Expands the Australia column to be able to retrieve OLAP members
// that correspond to the nested columns.
pivotGridControl1.ExpandValue(true, new object[] { "Australia" });
// Obtains OLAP members corresponding to the Australia and Bendigo values.
IOLAPMember countryMember = pivotGridControl1.GetFieldValueOLAPMember(fieldCountry, 0);
IOLAPMember cityMember = pivotGridControl1.GetFieldValueOLAPMember(fieldCity, 0);
// Exits if the OLAP members were not obtained successfully.
if (countryMember == null || cityMember == null)
return;
// 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 Fiscal Year field.
fieldFiscalYear.SortBySummaryInfo.Field = fieldInternetSalesAmount;
// Specifies a column by which the Fiscal Year field values should be sorted.
fieldFiscalYear.SortBySummaryInfo.Conditions.Add(
new PivotGridFieldSortCondition(fieldCountry, "Australia", countryMember.UniqueName));
fieldFiscalYear.SortBySummaryInfo.Conditions.Add(
new PivotGridFieldSortCondition(fieldCity, "Bendigo", cityMember.UniqueName));
}
finally {
// Unlocks the pivot grid and applies changes.
pivotGridControl1.EndUpdate();
}
}
}
}
Related GitHub Examples
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the GetFieldValueOLAPMember(PivotGridField, Int32) method.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.