Render HTML in Pivot Table

Comments

14 comments

  • Official comment
    Avatar
    Katie Garrison (Edited )

    Adding some steps to make a URL clickable within a pivot table:

    1. Create a custom column within the table with the URLs you would like to make clickable. In this example I called it HTMLURL

    Craft the HTML version of the link using <a href> tags. I used column "Link" as the URL and column "Name" as the display text

    '<a href="' + [Link] + '" target="_blank">' + [Name] + '</a>'

    This will create a column with the URL wrapped with HTML elements.

    3. Rebuild the cube to include the custom column

    4. Create a pivot table with the new column

    5. Edit the script of the widget, paste in the following script

    widget.on('ready', function(){
    var tags = $('tbody span:contains("<")');
    for(var i = 0; i<tags.length; i++){
    $(tags[i]).replaceWith(String(tags[i].textContent))
    }
    });

    6. Save the script and refresh the widget. The result should be a formatted link

    Hope that helps,
    Katie Garrison | Technical Solutions Consultant

    Comment actions Permalink
  • Avatar
    Katie Garrison

    Awesome, thanks for sharing Artem!

    1
    Comment actions Permalink
  • Avatar
    Brian Wilson

    Hi Artem,

    Would this work in a basic table widget as well?

    0
    Comment actions Permalink
  • Avatar
    Artem Yevtushenko

    Hi Brian, the basic table widget should do this automatically!

    The pivot table widget encloses the cell text with span elements, so special characters for HTML are ignored. The basic table widget does not have these, so it will accept any text, including HTML.

    1
    Comment actions Permalink
  • Avatar
    Paul Lam

    Does this script also render &nbsp; &reg; or &trade;? I applied the provided script and it doesn't seem too.

    0
    Comment actions Permalink
  • Avatar
    Artem Yevtushenko

    Hi Paul, I haven't tested this on those cases.

    I recommend doing string substitution in the elasticube.

    For example, edit the substring &nbsp to be " " in a custom column.

    0
    Comment actions Permalink
  • Avatar
    Shahar David

    Hey, 

    Thanks for this info.

    I've been trying to use that script in one of my dashboards but it seem that even when I add it as widget script it runs on the entire dashboard and effects all widgets. 

    Any ideas why?

     

    Thanks!

    0
    Comment actions Permalink
  • Avatar
    Ravid Paldi

    Hi Shahar, 

     

    Are you using hte exact same code from this post? 

    If so, then my guess is that is related to the JQuery selector as it uses a generic one (  $('tbody span:contains("<")') ) so it will "catch" ANY span element that has a "<" char within a tbody element - the element that initiates the table.  

     

    Cheers,

    Ravid

    0
    Comment actions Permalink
  • Avatar
    Shahar David

    Hey,

    Thanks for that, the script works well on the web browser. Once I try to export the report to PDF I get the blue marker but it's not clickable anymore. Anyway to solve this?

    Thanks!

    Shahar

    0
    Comment actions Permalink
  • Avatar
    Amit Agarwal

    Hi Katie,

    Thanks for the html custom field suggestion.

    But on filter, we could see the complete href as text value instead of the display text. This is troublesome to apply filters.

    Please let us know how to fix that.

     

    Thanks,

    Amit

    0
    Comment actions Permalink
  • Avatar
    Artem Yevtushenko

    Amit, duplicate the column in your table and remove the HTML keeping only the <a> tag text. Use this field for filtering instead. 

    0
    Comment actions Permalink
  • Avatar
    Sagi Nusseri

    Thank you for the script. It works!!

    Just 1 question, when we export the pivot to excel we see the HTML code and tags in this field.

    any solution for that? I would like to see only the text in the exported field.

    0
    Comment actions Permalink
  • Avatar
    Ahmed Yassine

    Is it possible to remove hyperlink when downloading the widget  into excel/csv and only keep the display name? 

    0
    Comment actions Permalink
  • Avatar
    Artem Yevtushenko

    Hi Ahmed,

    I always recommend having a separate table optimized for download.

    You can make a duplicate of the table that has the hyperlink removed live in a jump to dashboard that is accessed through a text box for example.

    A small text box above or below your pivot table can say go to printer friendly version and open the table with the raw data for export via Jump To Dashboard.

    Hope this helps

    1
    Comment actions Permalink

Please sign in to leave a comment.