AttributesGroups: IPivotGroupItems;
AttributesGroups: Prognoz.Platform.Interop.Pivot.IPivotGroupItems;
The AttributesGroups property returns the object used for grouping by attributes of sidehead or heading dimension elements.
To reorder grouping attributes, use the IPivotGroupItems.Move property.
Executing the example requires that the repository contains a regular report with the REPORT identifier. The report contains a table. A table data source is a cube that contains four dimensions. The sidehead dimension has at least three attributes, the heading dimension has five attributes.
Add links to the Dimensions, Drawing, Express, ForeSystem, Matrix, Metabase, Pivot, Report, Tab system assemblies.
Imports Prognoz.Platform.Interop.Dimensions;
Imports Prognoz.Platform.Interop.Drawing;
Imports Prognoz.Platform.Interop.Express;
Imports Prognoz.Platform.Interop.ForeSystem;
Imports Prognoz.Platform.Interop.Matrix;
Imports Prognoz.Platform.Interop.Pivot;
Imports Prognoz.Platform.Interop.Report;
Imports Prognoz.Platform.Interop.Tab;
…
Public Shared Sub Main(Params: StartParams);
Var
MB: IMetabase;
Report: IPrxReport;
Slice: IEaxDataAreaSlice;
Pivotslice: IEaxDataAreaPivotSlice;
Pivot: IPivot;
DimInst: IDimInstance;
PivotGroupItems: IPivotGroupItems;
PivotGroupItem: IPivotGroupItem;
PivotGroupAggregations: IPivotGroupAggregations;
DimselectionSet, Selection: IDimselectionSet;
Stylesettings: IDataAreaHeaderStyleSettingsBase;
HeaderStyle, DataStyle: ITabCellStyle;
GxColorCls: GxColorClass = New GxColorClassClass();
GxSolidBrushCls: GxSolidBrush = New GxSolidBrushClass();
Settings: IDataAreaHeaderSettingsBase;
Key: uinteger;
Viewsettings: IEaxGridViewSettings;
Pivotdim: IPivotDimension;
Method: BasicAggregatorOperation;
Begin
// Get repository
MB := Params.Metabase;
// Get report
Report := MB.ItemById["REPORT"].Edit() As IPrxReport;
// Get report slice
Slice := Report.DataArea.Slices.Item[0];
// Get object for working with table
Pivotslice := Slice As IEaxDataAreaPivotSlice;
Pivot := Pivotslice.Pivot;
// Set object for grouping by dimension element attributes
PivotGroupItems := Pivot.AttributesGroups;
// Determine parameters of displaying data table
Viewsettings := (Report.DataArea.Views.Item[0] As IEaxGrid).ViewSettings;
// Create a copy of dictionary selections
DimselectionSet := Pivot.Selection.CreateCopy();
// Remove selections
DimselectionSet.Clear();
// Add selection
DimselectionSet.Add(Pivot.DimItem[0]);
DimselectionSet.Item[0].SelectElement(1, False);
// Add dimension located in sidehead
DimInst := Pivot.DimItem[2];
Pivotdim := Pivot.Dimensions.FindByKey(DimInst.Key);
// Determine header formatting style
Settings := Pivotdim As IDataAreaHeaderSettingsBase;
Stylesettings := Pivotdim As IDataAreaHeaderStyleSettingsBase;
Viewsettings.GetStyleSettings[Stylesettings].Header.Font.Bold := TriState.tsOnOption;
Viewsettings.GetViewSettings[Settings].Hierarchical := TriState.tsOffOption;
// Determine grouping attribute
Key := DimInst.Attributes.Item[2].Attribute.Key;
// Add elements to grouping
PivotGroupItems.Clear();
PivotGroupItem := PivotGroupItems.Add();
PivotGroupItem.AttributeKey := Key;
PivotGroupItem.Dimension := DimInst;
// Set default aggregation
PivotGroupItem.DefaultAggregation := BasicAggregatorOperation.baoMin;
// Set row formatting
Stylesettings := PivotGroupItem As IDataAreaHeaderStyleSettingsBase;
HeaderStyle := Viewsettings.GetStyleSettings[Stylesettings].Header;
GxSolidBrushCls.Create(GxColorCls.FromName("Green"));
HeaderStyle.BackgroundBrush := GxSolidBrushCls;
DataStyle := Viewsettings.GetStyleSettings[Stylesettings].Data;
GxSolidBrushCls.Create(GxColorCls.FromName("Blue"));
DataStyle.Font.Color := GxColorCls.FromName("White");
DataStyle.BackgroundBrush := GxSolidBrushCls;
// Add dimension located in heading
DimInst := pivot.DimItem[3];
// Determine grouping attribute
Key := DimInst.Attributes.Item[4].Attribute.Key;
// Add elements to grouping
PivotGroupItem := PivotGroupItems.Add();
PivotGroupItem.AttributeKey := Key;
PivotGroupItem.Dimension := DimInst;
// Set column formatting
Stylesettings := PivotGroupItem As IDataAreaHeaderStyleSettingsBase;
HeaderStyle := Viewsettings.GetStyleSettings[Stylesettings].Header;
GxSolidBrushCls.Create(GxColorCls.FromName("Yellow"));
HeaderStyle.BackgroundBrush := GxSolidBrushCls;
DataStyle := Viewsettings.GetStyleSettings[Stylesettings].Data;
GxSolidBrushCls.Create(GxColorCls.FromName("Black"));
DataStyle.Font.Color := GxColorCls.FromName("White");
DataStyle.BackgroundBrush := GxSolidBrushCls;
// Set aggregation method for columns
PivotGroupAggregations := PivotGroupItem.AggregationMethods;
Method := BasicAggregatorOperation.baoSum;
Selection := DimselectionSet;
PivotGroupAggregations.Add(Selection, Method);
// Refresh object for working with table
Pivot.Refresh();
// Save report
(Report As IMetabaseObject).Save();
End Sub;
After executing the example, the table displays additional rows and columns with attribute names. These columns and rows display aggregated values. Formatting for rows and columns and their values is applied.
See also: