Jump to content
  • How to create hyperlinks in Cross Tables


    A known restriction of Spotfire is that URL or hyperlinks can be applied within a flat table but not in a Cross Table. Generally, once a table is transformed to a Cross Table  visualization, hyperlinks will be presented as text, not as links.

    There is a way to convert the text in a cross table to hyperlinks using some JavaScript.

    Screenshot2022-11-14at2_16_52PM.thumb.png.d3d1afc8ab4ac2df3f6a69756f0fc604.png

    The main prerequisite is only one table per page, and that you pre-load JQuery, as per: 

    In order to use JavaScript code, you need to create a text area. You can move it very far from the cross table and make it very small in order not to consume the report space. Then attach the following JS script to the text area.

    The main idea is to loop over cross-table cell values using jQuery and if the value contains "https" then the href attribute is applied. The listener is used to catch changes in div element as the script is launched before the cross table is loaded.

    var changeListener = function (event) {
        $(".sf-element-tabular-content div.sf-element-table-cell div.cell-text").each(function () {
            var cell_text = $(this).text();
            if (cell_text.includes("https") > 0) {
                $(this).replaceWith('<a href="' + cell_text + '" target="_blank"> ' + cell_text + "</a>");
            }
        });
    };
    var userSelection = document.getElementsByClassName("sf-element-tabular-content");
    for (var i = 0; i < userSelection.length; i++) {
        userSelection[i].addEventListener("DOMSubtreeModified", changeListener, false);
    }
     

     

    Result:

    Screenshot2022-11-14at2_17_02PM.thumb.png.5d1ad27e1508e218e7f94a3090298b6a.png

    links.dxp


    User Feedback

    Recommended Comments

    There are no comments to display.


×
×
  • Create New...