Knowledgebase: RadarCube ASP.NET MSAS
Initialization of the OLAP-slice view
Posted by - NA - on 09 February 2009 01:21 PM


Here is the description of the different ways of initial Grid loading, as well as the methods of program control over hierarchies and measures layout, drilling and cell sorting.

Program Control over the Cube Elements Layout

It is convenient, if upon the initial loading of the component, it displays the initial OLAP-slice. To do that, you need the appropriate hierarchies and measures to be displayed on the Grid axes, and perform the drilling of some hierarchy members.
RadarCube components allow a programmer to perform any initialization of the view of the OLAP-slice, connected to the Cube. By initialization here we mean a set of pivoting commands that allow you to receive the desired OLAP-slice view.
Pivoting commands can be executed at any moment, but every time they will cause a repainting of the Grid. If you don't need each change to be displayed, you can execute these commands in the batch mode (this will cause a single repainting of the Grid). To do that, you need to place the batch of commands between the pair commands:

// batch of operators


Program layout of a hierarchy is performed by passing it to a corresponding method. To place a hierarchy in the Grid, you need to call TCustomOLAPControl.PivotingFirst, specifying the area, where it should be placed to. To delete a hierarchy, use the TCustomOLAPControl.PivotingOut method.

Example. Initializing hierarchies' layout.

// method 1. Searching hierarchy by name
THierarchy h1 = Grid.Dimensions.FindHierarchy("[Product]");

// method 2. Searching hierarchy by display name
THierarchy h2 = Grid.Dimensions.FindHierarchyByDisplayName("Time");

// placing hierarchy in the top of the list of hierarchies on the row axis
Grid.PivotingFirst(h1, TLayoutArea.laRow);

// placing hierarchy in the top of the list of hierarchies on the column axis Grid.PivotingLast(h2, TLayoutArea.laColumn);


The Grid after execution of the code.

Measures in TOLAPGrid

Program layout of measures is simpler. You just need to assign the appropriate value to the TMeasure.Visible property. If it is set to true, the measure will be placed to the pivot area, otherwise - removed from it.

Example. Initialization of measures' layout.

// searching measure by name
TMeasure m1 = Grid.Measures.Find("[Measures].[Warehouse Sales]");
// searching measure by display name
TMeasure m2 = Grid.Measures.FindByDisplayName("Sales Count");

// placing measure in the Grid
m1.Visible = true;
m2.Visible = true;

The Grid with initialized hierarchies and measures.

Measures in TOLAPChart

Measures in TOLAPChart are grouped in lists, like TMeasureGroup. They allow building separate charts for different dimensions. Upon initialization you can choose between building individual series and gathering the series, generated by the same measure, in a separate group. The measures placed in the row area set contiguous vertical axes.

The TOLAPChart component allows you to place measures into the column area, though only one measure can be put there. The measure placed in the column area sets a contiguous horizontal axis.

Example 1. Placing measures in the row area.

The example code creates two groups of measures. The first contains the "Sales Count" measure, the second - both "Store Cost" and "Store Invoice" measures.

// placing the measure to a new group
TMeasure measure = Grid.Measures.Find("[Measures].[Sales Count]");
Grid.Pivoting(measure, TLayoutArea.laRow, null);

// creating a group of measures
measure = Grid.Measures.Find("[Measures].[Store Cost]");
TMeasureGroup group = Grid.Pivoting(measure, TLayoutArea.laRow, null);

measure = Grid.Measures.Find("[Measures].[Store Invoice]");
Grid.Pivoting(measure, TLayoutArea.laRow, group);

The measures placed in the row area set contiguous vertical axes

The Grid with two groups of measures.

Example 2. Placing measures in the column area.

The example code places the "Sales Count" measure in the group into the row area, and the "Store Cost" measure - into the column area.

// placing the measure into the row area.
TMeasure measure = Grid.Measures.Find("[Measures].[Sales Count]");
Grid.Pivoting(measure, TLayoutArea.laRow, null);

// placing the measure into the column area.
measure = Grid.Measures.Find("[Measures].[Store Cost]");
Grid.Pivoting(measure,TLayoutArea.laColumn, null);

The Grid with a measure in the column area.


Before you'll be able to perform the drilling operation, you have to get a reference to the Grid cell interface. The simplest way to do it is through the TCustomOLAPControl.CellSet property.

Example. Drilling operation.

// searching hierarchy by name THierarchy h1 = Grid.Dimensions.FindHierarchy("[Product]");
// placing a hierarchy on top of the list of hierarchies on the row axis Grid.PivotingFirst(h1, TLayoutArea.laRow);
// Rebuilding a set of cells Grid.CellSet.Rebuild();
// searching reference to the IMemberCell interface by display name IMemberCell cell = Grid.CellSet.FindMember("Food"); if (cell != null) cell.DrillAction(TPossibleDrillActions.esNextLevel);
// getting reference to the interface by the absolute position in the OLAP-slice cell = (IMemberCell)Grid.CellSet.Cells(0, 2); cell.DrillAction(TPossibleDrillActions.esNextLevel);

Note 1. You'll have to call the Grid.CellSet.Rebuild() method in the set of batch files, if there were any changes in the set of the Grid's pivot panels.

Note 2. The IMemberCell.PossibleDrillActions property contains the set of drilling actions available for the hierarchy member.


Sorting of the Grid columns is initialized by a couple of properties, specifying the number of the sorted column and the sorting direction. To cancel sorting you need to set the sorted column number to -1.

Example. Ascending sorting of the third column.

Grid.CellSet.ValueSortedColumn = 2;
Grid.CellSet.ValueSortingDirection = TValueSortingDirection.sdAscending;

Saving and Loading the Grid State from a File

The Grid provides you with the ability to save the Cube elements layout in an outside file, using the methods of saving/loading data in the usual or compressed format.

Example 1. Pre-saving of the Grid state

// saving the full set of properties
Grid.SaveCompressed(@"C:\All.rsdata", TStreamContent.All);

// saving the Cube data (for the DESKTOP version only)
Grid.SaveCompressed(@"C:\Data.rsdata", TStreamContent.CubeData);

// saving the Grid visual settings
Grid.SaveCompressed(@"C:\Appearance.rsdata", TStreamContent.GridAppearance);

Note 1. The TCustomOLAPControl.SaveUncompressed method saves the uncompressed data.

Note 2. The component has a set of override methods SaveUncompressed\SaveCompressed that save the Grid state into a stream.

Note 3. Loading the Grid state. Upon loading the Grid state, the component will automatically recognize the type of data (compressed or uncompressed) and perform the initialization of properties.

// loading file "Appearance.rsdata".

(372 vote(s))
This article was helpful
This article was not helpful

Help Desk Software by Kayako Resolve