<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to show a hidden field in a tooltip when I hover over rows in the table? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-show-a-hidden-field-in-a-tooltip-when-I-hover-over-rows/m-p/275523#M83107</link>
    <description>&lt;P&gt;Disclaimer: I don’t pretend to know a lot about Javascript and have only come to this answer through needing it myself and hacked my way through it. Though considering there is no answer here and I have a working example, I thought it best to share. It is based on a combination of:&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;The blog mentioned: &lt;A href="https://www.splunk.com/blog/2014/01/29/add-a-tooltip-to-simple-xml-tables-with-bootstrap-and-a-custom-cell-renderer.html"&gt;https://www.splunk.com/blog/2014/01/29/add-a-tooltip-to-simple-xml-tables-with-bootstrap-and-a-custom-cell-renderer.html&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;This Splunk answer for the hidden field: &lt;A href="https://answers.splunk.com/answers/592103/how-can-i-show-multiple-values-on-a-tooltip-from-a.html"&gt;https://answers.splunk.com/answers/592103/how-can-i-show-multiple-values-on-a-tooltip-from-a.html&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;The “Table Row Highlighting” example from the Splunk Dashboard Examples app: &lt;A href="https://splunkbase.splunk.com/app/1603/"&gt;https://splunkbase.splunk.com/app/1603/&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;And various jquery examples found throughout stackovervflow.com &lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;I have found that however the behavior is inconsistent on tables that take a long time to load (like from a long search—it has trouble setting the data-toggle value) but otherwise works as expected (maybe someone else will have that issue and provide their fix). &lt;/P&gt;

&lt;P&gt;A rough explanation of what I am doing is&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;Combining the “hidden” field into one that can be seen (because it doesn’t seem to be able to use it otherwise) and splitting it apart for use for the tooltip&lt;/LI&gt;
&lt;LI&gt;Using the BaseCellRenderer, moving the hidden text from the split into a hidden span section in that cell&lt;/LI&gt;
&lt;LI&gt;Then finding that span and setting the parent (row) to have the data-toggle set to tooltip&lt;/LI&gt;
&lt;LI&gt;Then setting the tooltip text to match the hidden span’s value&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;Here is a basic example of what you where mentioning, the dashboard xml and the javascript code.&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Dashboard (Note I am going the long way about so that it is hopefully clear about the combining fields):&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;dashboard stylesheet="rowtooltip.css" script="rowtooltip.js"&amp;gt;
  &amp;lt;init&amp;gt;
    &amp;lt;unset token="search"&amp;gt;&amp;lt;/unset&amp;gt;
  &amp;lt;/init&amp;gt;
  &amp;lt;label&amp;gt;Address Test&amp;lt;/label&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;table id="rowtooltip"&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;| makeresults
| eval combined = "Bruce,Wayne,Gotham City|Clark,Kent,Metropolis|Peter,Parker,New York City"
| eval combined = split(combined, "|")
| mvexpand combined
| rex field=combined "(?&amp;lt;First&amp;gt;[^,]+),(?&amp;lt;Last&amp;gt;[^,]+),(?&amp;lt;Address&amp;gt;[^\$]+)"
| table First Last Address
| eval Last = Last."####".Address
| table First Last&amp;lt;/query&amp;gt;
          &amp;lt;earliest&amp;gt;-24h@h&amp;lt;/earliest&amp;gt;
          &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;option name="count"&amp;gt;10&amp;lt;/option&amp;gt;
        &amp;lt;option name="drilldown"&amp;gt;none&amp;lt;/option&amp;gt;
        &amp;lt;option name="refresh.display"&amp;gt;progressbar&amp;lt;/option&amp;gt;
      &amp;lt;/table&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
&amp;lt;/dashboard&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;Javascript:&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;require([
    'underscore',
    'jquery',
    'splunkjs/mvc',
    'splunkjs/mvc/tableview',
    'splunkjs/mvc/simplexml/ready!'
], function(_, $, mvc, TableView) {

    var CustomTooltipRenderer = TableView.BaseCellRenderer.extend({
        canRender: function(cell) {
            return cell.field === 'Last';
        },
        render: function($td, cell) {

            //split the cell to extract the text for the tooltip and hide it
            var message = cell.value.split('####')[0];
            var tip = cell.value.split('####')[1];

            $td.html(_.template('&amp;lt;%- message%&amp;gt;&amp;lt;span style="display:none" class="tip"&amp;gt;&amp;lt;%- tip%&amp;gt;&amp;lt;/span&amp;gt;', {
                message: message,
                tip: tip,
            })); 

            // label the class to find it later
            $td.addClass('carrier-cell');
        }
    });

mvc.Components.get('rowtooltip').getVisualization(function(tableView) {

        // Register custom cell renderer
        tableView.table.addCellRenderer(new CustomTooltipRenderer());

        tableView.on('rendered', function() {
            // Apply class of the cells to the parent row in order to color the whole row
            tableView.$el.find('td.carrier-cell').each(function() {
                // Grab the hidden value from the carrier cell to display in tooltip
                var message = $(this).find('span').html();
                // Set the tool tip on the cell's parent row
                $(this).parents('tr').attr('data-toggle','tooltip').tooltip({title: message, placement: 'top'});
            });
            tableView.$el.find('[data-toggle="tooltip"]').tooltip();
        });

        // Force the table to re-render
        tableView.table.render();        
    });

});
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;With the result effect being:&lt;BR /&gt;
&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/2423i4047040189307938/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 06 Nov 2018 19:48:21 GMT</pubDate>
    <dc:creator>worshamn</dc:creator>
    <dc:date>2018-11-06T19:48:21Z</dc:date>
    <item>
      <title>How to show a hidden field in a tooltip when I hover over rows in the table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-show-a-hidden-field-in-a-tooltip-when-I-hover-over-rows/m-p/275522#M83106</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;

&lt;P&gt;I'm trying to do something like this: &lt;BR /&gt;
&lt;A href="http://blogs.splunk.com/2014/01/29/add-a-tooltip-to-simple-xml-tables-with-bootstrap-and-a-custom-cell-renderer/"&gt;http://blogs.splunk.com/2014/01/29/add-a-tooltip-to-simple-xml-tables-with-bootstrap-and-a-custom-cell-renderer/&lt;/A&gt;&lt;BR /&gt;
but for a hidden field. &lt;/P&gt;

&lt;P&gt;For example I have a table with two fields: "First Name"  &amp;amp; "Last Name" shown in my dashboard, and I have also a hidden column "Address" from the search. My question is how to show the hidden field "Address" in a tooltip when I hover over the rows of the table.&lt;/P&gt;

&lt;P&gt;I appreciate any help!&lt;/P&gt;</description>
      <pubDate>Fri, 03 Feb 2017 15:49:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-show-a-hidden-field-in-a-tooltip-when-I-hover-over-rows/m-p/275522#M83106</guid>
      <dc:creator>bjoukhadar</dc:creator>
      <dc:date>2017-02-03T15:49:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to show a hidden field in a tooltip when I hover over rows in the table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-show-a-hidden-field-in-a-tooltip-when-I-hover-over-rows/m-p/275523#M83107</link>
      <description>&lt;P&gt;Disclaimer: I don’t pretend to know a lot about Javascript and have only come to this answer through needing it myself and hacked my way through it. Though considering there is no answer here and I have a working example, I thought it best to share. It is based on a combination of:&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;The blog mentioned: &lt;A href="https://www.splunk.com/blog/2014/01/29/add-a-tooltip-to-simple-xml-tables-with-bootstrap-and-a-custom-cell-renderer.html"&gt;https://www.splunk.com/blog/2014/01/29/add-a-tooltip-to-simple-xml-tables-with-bootstrap-and-a-custom-cell-renderer.html&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;This Splunk answer for the hidden field: &lt;A href="https://answers.splunk.com/answers/592103/how-can-i-show-multiple-values-on-a-tooltip-from-a.html"&gt;https://answers.splunk.com/answers/592103/how-can-i-show-multiple-values-on-a-tooltip-from-a.html&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;The “Table Row Highlighting” example from the Splunk Dashboard Examples app: &lt;A href="https://splunkbase.splunk.com/app/1603/"&gt;https://splunkbase.splunk.com/app/1603/&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;And various jquery examples found throughout stackovervflow.com &lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;I have found that however the behavior is inconsistent on tables that take a long time to load (like from a long search—it has trouble setting the data-toggle value) but otherwise works as expected (maybe someone else will have that issue and provide their fix). &lt;/P&gt;

&lt;P&gt;A rough explanation of what I am doing is&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;Combining the “hidden” field into one that can be seen (because it doesn’t seem to be able to use it otherwise) and splitting it apart for use for the tooltip&lt;/LI&gt;
&lt;LI&gt;Using the BaseCellRenderer, moving the hidden text from the split into a hidden span section in that cell&lt;/LI&gt;
&lt;LI&gt;Then finding that span and setting the parent (row) to have the data-toggle set to tooltip&lt;/LI&gt;
&lt;LI&gt;Then setting the tooltip text to match the hidden span’s value&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;Here is a basic example of what you where mentioning, the dashboard xml and the javascript code.&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Dashboard (Note I am going the long way about so that it is hopefully clear about the combining fields):&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;dashboard stylesheet="rowtooltip.css" script="rowtooltip.js"&amp;gt;
  &amp;lt;init&amp;gt;
    &amp;lt;unset token="search"&amp;gt;&amp;lt;/unset&amp;gt;
  &amp;lt;/init&amp;gt;
  &amp;lt;label&amp;gt;Address Test&amp;lt;/label&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;table id="rowtooltip"&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;| makeresults
| eval combined = "Bruce,Wayne,Gotham City|Clark,Kent,Metropolis|Peter,Parker,New York City"
| eval combined = split(combined, "|")
| mvexpand combined
| rex field=combined "(?&amp;lt;First&amp;gt;[^,]+),(?&amp;lt;Last&amp;gt;[^,]+),(?&amp;lt;Address&amp;gt;[^\$]+)"
| table First Last Address
| eval Last = Last."####".Address
| table First Last&amp;lt;/query&amp;gt;
          &amp;lt;earliest&amp;gt;-24h@h&amp;lt;/earliest&amp;gt;
          &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;option name="count"&amp;gt;10&amp;lt;/option&amp;gt;
        &amp;lt;option name="drilldown"&amp;gt;none&amp;lt;/option&amp;gt;
        &amp;lt;option name="refresh.display"&amp;gt;progressbar&amp;lt;/option&amp;gt;
      &amp;lt;/table&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
&amp;lt;/dashboard&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;Javascript:&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;require([
    'underscore',
    'jquery',
    'splunkjs/mvc',
    'splunkjs/mvc/tableview',
    'splunkjs/mvc/simplexml/ready!'
], function(_, $, mvc, TableView) {

    var CustomTooltipRenderer = TableView.BaseCellRenderer.extend({
        canRender: function(cell) {
            return cell.field === 'Last';
        },
        render: function($td, cell) {

            //split the cell to extract the text for the tooltip and hide it
            var message = cell.value.split('####')[0];
            var tip = cell.value.split('####')[1];

            $td.html(_.template('&amp;lt;%- message%&amp;gt;&amp;lt;span style="display:none" class="tip"&amp;gt;&amp;lt;%- tip%&amp;gt;&amp;lt;/span&amp;gt;', {
                message: message,
                tip: tip,
            })); 

            // label the class to find it later
            $td.addClass('carrier-cell');
        }
    });

mvc.Components.get('rowtooltip').getVisualization(function(tableView) {

        // Register custom cell renderer
        tableView.table.addCellRenderer(new CustomTooltipRenderer());

        tableView.on('rendered', function() {
            // Apply class of the cells to the parent row in order to color the whole row
            tableView.$el.find('td.carrier-cell').each(function() {
                // Grab the hidden value from the carrier cell to display in tooltip
                var message = $(this).find('span').html();
                // Set the tool tip on the cell's parent row
                $(this).parents('tr').attr('data-toggle','tooltip').tooltip({title: message, placement: 'top'});
            });
            tableView.$el.find('[data-toggle="tooltip"]').tooltip();
        });

        // Force the table to re-render
        tableView.table.render();        
    });

});
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;With the result effect being:&lt;BR /&gt;
&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/2423i4047040189307938/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Nov 2018 19:48:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-show-a-hidden-field-in-a-tooltip-when-I-hover-over-rows/m-p/275523#M83107</guid>
      <dc:creator>worshamn</dc:creator>
      <dc:date>2018-11-06T19:48:21Z</dc:date>
    </item>
  </channel>
</rss>

