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.
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.
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
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
The measures placed in the row area set contiguous vertical axes
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.
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.
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;
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
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".