Show contents 

Reference > Setting Up Object Formatting in the Desktop Application > Working with Formatting Dialog Box > Hyperlink > Example

Example

Executing the example requires a regular report with a data source, the created data area or table visualizer with the EaxObject identifier.

If it is assumed to used Fore method, go to Step 1. If it is assumed to work in the web application and use JavaScript, go to Step 2.

Step 1. Creating a Procedure

To create a macro, select the Create > Development Environment > Unit item in the context menu of the Object Navigator window. The development environment dialog box opens.

Add links to the Dimensions, Express, Matrix, Pivot, Report, Tab, Ui system assemblies. To do that, select the Assembly > Edit Links item. In the Assembly Links dialog box that opens on the System Assemblies tab, select checkboxes next to the required assemblies names.

Enter the following code in the development environment window:

Sub AttributeValue(FocusedRow: Integer; FocusedColumn: Integer);
Var
    Report: IPrxReport;
    Tab: ITabSheet;
    DataArea: IEaxDataAreaViews;
    Grid: IEaxGrid;
    Result_eax: IEaxDrillResult;
    Result_prx: IPrxDrillCellResult;
    Slice_eax: IEaxDataAreaPivotSlice;
    Slice_prx: IPrxSlice;
    Dim: IDimInstance;
    DimSelection: IDimSelection;
    Dim_prx: IPrxSliceDimension;
    DimAttr: IDimAttributeInstance;
    DimElements: IDimElements;
    DataBinding: IPrxTableDataBinding;
    DimInd, Ind: Integer;
    AttrValue: Variant;
Begin
    Report := PrxReport.ActiveReport;
    Tab := (Report.ActiveSheet As IPrxTable).TabSheet;
    // === Table visualizer ===
    DataArea := Report.DataArea.Views;
    Grid := DataArea.FindById("EaxObject"As IEaxGrid;
    Result_eax := Grid.DrillCellResult(FocusedRow, FocusedColumn);
    If Result_eax <> Null Then
        Slice_eax := Grid.Slice As IEaxDataAreaPivotSlice;
        Dim := Slice_eax.Pivot.LeftHeader.Dim(0);
        DimSelection := Result_eax.Selection.FindByKey(Dim.Key);
        WinApplication.InformationBox("Dimension selection " + Dim.Ident + " after drilldown: " + DimSelection.ToString);
    End If;
    // === Data area ===
    DataBinding := (Report.ActiveSheet As IPrxTable).DataBinding;
    Result_prx := DataBinding.DrillCell(FocusedRow, FocusedColumn);
    If Result_prx <> Null Then
        Slice_prx := Report.DataSources.Item(0).Slices.Item(0);
        Dim_prx := Slice_prx.LeftHeader.Item(0);
        DimInd := Slice_prx.Selection.IndexOfKey(Dim_prx.Key);
        Ind := Result_prx.Coord.Item(DimInd);
        DimAttr := Dim_prx.Dimension.Attributes.Item(0);
        DimSelection := Result_prx.Selection.Item(DimInd);
        DimElements := DimSelection.Dimension.Elements;
        AttrValue := DimElements.AttributeValueO(Ind, DimAttr);
        WinApplication.InformationBox("Attribute value " + DimAttr.Attribute.Id + ": " + AttrValue);
    End If;
End Sub AttributeValue;

After the unit is created and saved, connect it to the report.

Step 2. Creating a Custom JS-Function

If it is required that a link opens in the web application, create a custom JS-function identical to the Fore procedure and connect it to the report. For details about signature and connecting JS-function to regular report see the  Connecting Custom JS-Function to Report section.

Step 3. Creating a Hyperlink

Open the Cell Format dialog box for the regular report cell, go to the Hyperlink tab. If a unit was created and connected, select it in the Unit box and specify procedure call in the Procedure/Function box. If JavaScript function was created, specify its call in the JS-Function box.

NOTE. The considered example contains numbers of data area row and column as procedure parameters: AttributeValue(3, 3).

Result

A cell containing a hyperlink looks as follows:

Click the cell with hyperlink.

After executing the example, attributes of data area element are obtained by the selected data area cell. For example:

See also:

Hyperlink