Add(Value: Variant): Integer;
Value. Value of detailing substitution.
The Add method adds a value of detailing substitution to the collection.
The method returns the key of the value of detailing substitution added to the collection.
Numbering of collection elements starts from zero. If elements were removed from the collection using the IEaxDrillSettingsValues.RemoveAt method, the new element will be added with the least free key. To get an array of existing keys, use the IEaxDrillSettingsValues.Keys property.
Executing the example requires that the repository contains a regular report with the REG_VALUES identifier. A data source is a cube with a calendar dimension. The report contains one sheet, on which an analytical data area is created.
Add links to the Dimensions, Express, Metabase, Pivot, Report, and Tab system assemblies.
Sub UserProc;
Var
MB: IMetabase;
Rep: IPrxReport;
PivSlice: IEaxDataAreaPivotSlice;
Pivot: IPivot;
HeadSets: IDataAreaHeaderSettingsBase;
Grid: IEaxGrid;
DimSettings: IEaxGridDimensionSettings;
PivotDims: IPivotDimension;
DimModel: IDimensionModel;
DimIndex: IDimIndex;
Attributes: IDimAttributesInstance;
Attribute: IDimAttribute;
Drill: IEaxDrillSettings;
ElementKey : Integer;
Begin
// Get repository
MB := MetabaseClass.Active;
// Get regular report
Rep := MB.ItemById("REG_VALUES").Edit As IPrxReport;
// Get data slice as a data area of report table
PivSlice := Rep.DataArea.Slices.Item(0) As IEaxDataAreaPivotSlice;
// Get data table
Pivot := PivSlice.Pivot;
// Get the Calendar dimension
PivotDims := Pivot.Dimensions.Item(1);
// Get dimension structure
DimModel := PivotDims.DimInstance.Dimension;
// Get structure of the specified dimension index
DimIndex := DimModel.Indexes.Item(0);
// Get collection of dimension attributes
Attributes := PivotDims.DimInstance.Attributes;
// Get structure of the specified attribute
Attribute := Attributes.Item(0).Attribute;
// Get analytical data area header settings
HeadSets := PivotDims As IDataAreaHeaderSettingsBase;
// Enable detailing settings for the specified view
Grid := (PivSlice As IEaxDataAreaSlice).Views.Item(0) As IEaxGrid;
Grid.ViewSettings.HyperlinkAsText := False;
DimSettings := Grid.ViewSettings.GetViewSettings(HeadSets) As IEaxGridDimensionSettings;
If Not DimSettings.IsDrilled Then
DimSettings.Drilled := TriState.OnOption;
End If;
// Get detailing settings
Drill := DimSettings.Drill;
// Specify sheet
Drill.SheetKey := Rep.Sheets.Item(0).Key;
// Specify dimension
Drill.Dimension := PivotDims;
// Set method for changing selection - replacement
Drill.Mode := EaxDataDrillMode.Replace;
// Set index for element search
Drill.DimensionIndex := DimIndex;
// Set attribute of search in index
Drill.DimensionAttribute := Attribute;
Drill.DimensionAttributes := "BLOCK_TYPE";
// The specified website will open on hyperlink click
// The URL will open on a new browser tab
Drill.ActionType := TabHyperlinkActionType.OpenURL;
// Clear collection of possible already stored values
Drill.Values.Clear;
//Add a substitution value to collection and temporarily save its key
ElementKey := Drill.Values.Add("first element of collection");
// Display this collection element in the console
Debug.WriteLine("Key of added element: " + ElementKey.ToString);
Debug.WriteLine("Value of added element: " + Drill.Values.GetAt(ElementKey));
Debug.WriteLine("");
// Add another substitution value but without saving key
Drill.Values.Add("second element in collection");
// Get key of new element
ElementKey := Drill.Values.Keys[Drill.Values.Count - 1];
// Display this collection element in the console
Debug.WriteLine("Key of added element: " + ElementKey.ToString);
Debug.WriteLine("Value of added element: " + Drill.Values.GetAt(ElementKey));
Debug.WriteLine("");
// Add the third substitution value but right before displaying in the console
Debug.WriteLine("Key of added element: " + Drill.Values.Add("Substitution No. 3").ToString);
Debug.WriteLine("Value of added element: " + Drill.Values.GetAt(Drill.Values.Keys[Drill.Values.Count - 1]));
Debug.WriteLine("");
// Display list of keys in the console
Debug.WriteLine("List of keys:");
For Each ElementKey In Drill.Values.Keys Do
Debug.WriteLine(ElementKey);
End For;
Debug.WriteLine("");
// Remove the second element of collection
Debug.WriteLine("Indicates whether existing element was removed successfully: " + Drill.Values.RemoveAt(1).ToString);
// Try to remove it again
Debug.WriteLine("Indicates whether absent element was removed successfully: " + Drill.Values.RemoveAt(1).ToString);
// Display list of keys after element removal in the console
Debug.WriteLine("List of keys after removal of element with the 1 key:");
For Each ElementKey In Drill.Values.Keys Do
Debug.WriteLine(ElementKey);
End For;
Debug.WriteLine("");
// Add a new element and define its key
ElementKey := Drill.Values.Add("Fourth (in the order of adding)");
// Display this collection element in the console
Debug.WriteLine("Key of added element: " + ElementKey.ToString);
Debug.WriteLine("Value of added element: " + Drill.Values.GetAt(ElementKey));
Debug.WriteLine("");
// Display list of keys after adding an element
Debug.WriteLine("List of keys after adding an element:");
For Each ElementKey In Drill.Values.Keys Do
Debug.WriteLine(ElementKey);
End For;
Debug.WriteLine("");
// Change value of the first element
Drill.Values.SetAt(0, "Edited substitution");
// Display it in the console:
Debug.WriteLine("New value of the first element: " + Drill.Values.GetAt(0));
Debug.WriteLine("");
Debug.WriteLine("List of collection elements:");
Debug.WriteLine(Drill.Values.GetAt(0));
Debug.WriteLine(Drill.Values.GetAt(1));
Debug.WriteLine(Drill.Values.GetAt(2));
// Specify required keys of collection elements as substitutions.
// The browser will show search query with values of collection elements,
// which keys are specified in the substitution
Drill.Action := "http://www.google.com/search?q=&[2] and &[0]";
Drill.Target := TabHyperlinkTarget.Top;
// Refresh report and save changes
Rep.Recalc;
(Rep As IMetabaseObject).Save;
End Sub UserProc;
After executing the example:
Dimension elements detailing will be used for the specified regular report.
The specified hyperlink will open on on clicking the dimension element. Values of collection elements with the specified keys will be inserted to the hyperlink.
See also: