<?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 How to add icons for the multiple fields in splunk table in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-icons-for-the-multiple-fields-in-splunk-table/m-p/446039#M33268</link>
    <description>&lt;P&gt;I have multiple columns in my table .Fields having values either "Yes" or "No". Yes will be displayed as check-circle icon and No will be displayed as x-circle icon.Whats the missing thing in the below js.&lt;/P&gt;
&lt;P&gt;Eg. Wireless and VSP are the fields .Below is the js .&lt;/P&gt;
&lt;P&gt;require([&lt;BR /&gt;'underscore',&lt;BR /&gt;'jquery',&lt;BR /&gt;'splunkjs/mvc',&lt;BR /&gt;'splunkjs/mvc/tableview',&lt;BR /&gt;'splunkjs/mvc/simplexml/ready!'&lt;BR /&gt;], function(_, $, mvc, TableView) {&lt;BR /&gt;// Translations from rangemap results to CSS class&lt;BR /&gt;var ICONS = {&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;    No: 'x-circle',
    Yes: 'check-circle'
};
var RangeMapIconRenderer = TableView.BaseCellRenderer.extend({
    canRender: function(cell) {
        // Only use the cell renderer for the range field
        return cell.field === 'Wireless';

    },
    render: function($td, cell) {
        var icon = 'question';
        // Fetch the icon for the value
        if (ICONS.hasOwnProperty(cell.value)) {
            icon = ICONS[cell.value];
        }
        // Create the icon element and add it to the table cell
        $td.addClass('icon').html(_.template('&amp;lt;i class="icon-&amp;lt;%-icon%&amp;gt; &amp;lt;%- Wireless %&amp;gt;" title="&amp;lt;%- Wireless %&amp;gt;"&amp;gt;&amp;lt;/i&amp;gt;', {
            icon: icon,
            Wireless: cell.value
        }));
    }
});
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;var RangeMapIconRenderer = TableView.BaseCellRenderer.extend({&lt;BR /&gt;canRender: function(cell) {&lt;BR /&gt;// Only use the cell renderer for the range field&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;        return cell.field === 'VSP';
    },
    render: function($td, cell) {
        var icon = 'question';
        // Fetch the icon for the value
        if (ICONS.hasOwnProperty(cell.value)) {
            icon = ICONS[cell.value];
        }
        // Create the icon element and add it to the table cell
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;$td.addClass('icon').html(_.template('&lt;I&gt;&lt;/I&gt;', {&lt;BR /&gt;icon: icon,&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;            VSP: cell.value
        }));
    }
});

mvc.Components.get('table1').getVisualization(function(tableView){
    // Register custom cell renderer, the table will re-render automatically
    tableView.addCellRenderer(new RangeMapIconRenderer());
});
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;});&lt;/P&gt;</description>
    <pubDate>Mon, 08 Jun 2020 15:40:58 GMT</pubDate>
    <dc:creator>Nadhiyaa</dc:creator>
    <dc:date>2020-06-08T15:40:58Z</dc:date>
    <item>
      <title>How to add icons for the multiple fields in splunk table</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-icons-for-the-multiple-fields-in-splunk-table/m-p/446039#M33268</link>
      <description>&lt;P&gt;I have multiple columns in my table .Fields having values either "Yes" or "No". Yes will be displayed as check-circle icon and No will be displayed as x-circle icon.Whats the missing thing in the below js.&lt;/P&gt;
&lt;P&gt;Eg. Wireless and VSP are the fields .Below is the js .&lt;/P&gt;
&lt;P&gt;require([&lt;BR /&gt;'underscore',&lt;BR /&gt;'jquery',&lt;BR /&gt;'splunkjs/mvc',&lt;BR /&gt;'splunkjs/mvc/tableview',&lt;BR /&gt;'splunkjs/mvc/simplexml/ready!'&lt;BR /&gt;], function(_, $, mvc, TableView) {&lt;BR /&gt;// Translations from rangemap results to CSS class&lt;BR /&gt;var ICONS = {&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;    No: 'x-circle',
    Yes: 'check-circle'
};
var RangeMapIconRenderer = TableView.BaseCellRenderer.extend({
    canRender: function(cell) {
        // Only use the cell renderer for the range field
        return cell.field === 'Wireless';

    },
    render: function($td, cell) {
        var icon = 'question';
        // Fetch the icon for the value
        if (ICONS.hasOwnProperty(cell.value)) {
            icon = ICONS[cell.value];
        }
        // Create the icon element and add it to the table cell
        $td.addClass('icon').html(_.template('&amp;lt;i class="icon-&amp;lt;%-icon%&amp;gt; &amp;lt;%- Wireless %&amp;gt;" title="&amp;lt;%- Wireless %&amp;gt;"&amp;gt;&amp;lt;/i&amp;gt;', {
            icon: icon,
            Wireless: cell.value
        }));
    }
});
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;var RangeMapIconRenderer = TableView.BaseCellRenderer.extend({&lt;BR /&gt;canRender: function(cell) {&lt;BR /&gt;// Only use the cell renderer for the range field&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;        return cell.field === 'VSP';
    },
    render: function($td, cell) {
        var icon = 'question';
        // Fetch the icon for the value
        if (ICONS.hasOwnProperty(cell.value)) {
            icon = ICONS[cell.value];
        }
        // Create the icon element and add it to the table cell
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;$td.addClass('icon').html(_.template('&lt;I&gt;&lt;/I&gt;', {&lt;BR /&gt;icon: icon,&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;            VSP: cell.value
        }));
    }
});

mvc.Components.get('table1').getVisualization(function(tableView){
    // Register custom cell renderer, the table will re-render automatically
    tableView.addCellRenderer(new RangeMapIconRenderer());
});
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;});&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jun 2020 15:40:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-icons-for-the-multiple-fields-in-splunk-table/m-p/446039#M33268</guid>
      <dc:creator>Nadhiyaa</dc:creator>
      <dc:date>2020-06-08T15:40:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to add icons for the multiple fields in splunk table</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-icons-for-the-multiple-fields-in-splunk-table/m-p/446040#M33269</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;

&lt;P&gt;Try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;dashboard script="table.js"&amp;gt;
  &amp;lt;label&amp;gt;Icon&amp;lt;/label&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;html&amp;gt;
      &amp;lt;head&amp;gt;
        &amp;lt;style&amp;gt;
          .yes {
              background-image: url('/static/app/search/images/yes.png') !important;
              background-repeat: no-repeat !important;
              background-size: 20px 20px; !important;
          }
          .no {
              background-image: url('/static/app/search/images/no.png') !important;
              background-repeat: no-repeat !important;
              background-size: 20px 20px; !important;
          }
        &amp;lt;/style&amp;gt;
      &amp;lt;/head&amp;gt;
    &amp;lt;/html&amp;gt;
  &amp;lt;/row&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;table id="sample"&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;| makeresults 
| eval Wireless = "Yes,No,Yes,Yes,No" 
| makemv delim="," Wireless 
| mvexpand Wireless 
| appendcols 
    [| makeresults 
    | eval VSP = "No,No,Yes,Yes,Yes" 
    | makemv delim="," VSP 
    | mvexpand VSP ] 
| appendcols 
    [| makeresults 
    | eval Others = "1,2,3,4,5" 
    | makemv delim="," Others 
    | mvexpand Others ] 
| table Wireless,VSP,Others&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="drilldown"&amp;gt;none&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;java script:&lt;CODE&gt;table.js&lt;/CODE&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 CustomRangeRenderer = TableView.BaseCellRenderer.extend({
        canRender: function(cell) {
            return _(['Wireless','VSP']).contains(cell.field);
        },
        render: function($td, cell) {
            var value = cell.value;
            if(value=="Yes" )
                {
                    $td.html("&amp;lt;div class='yes'&amp;gt; &amp;lt;/div&amp;gt;")
                }
            else
            {
                    $td.html("&amp;lt;div class='no'&amp;gt; &amp;lt;/div&amp;gt;")
            }
         }
    });

    var sh = mvc.Components.get("sample");
    if(typeof(sh)!="undefined") {
        sh.getVisualization(function(tableView) {
            // Add custom cell renderer and force re-render
            tableView.table.addCellRenderer(new CustomRangeRenderer());
            tableView.table.render();
        });
    }

  });  
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In this sample, I had placed two images yes.png and no.png under &lt;CODE&gt;/opt/splunk/etc/apps/search/appserver/static/images/&lt;/CODE&gt; modify it accordingly to your need.&lt;/P&gt;</description>
      <pubDate>Sun, 30 Jun 2019 14:49:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-icons-for-the-multiple-fields-in-splunk-table/m-p/446040#M33269</guid>
      <dc:creator>vnravikumar</dc:creator>
      <dc:date>2019-06-30T14:49:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to add icons for the multiple fields in splunk table</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-icons-for-the-multiple-fields-in-splunk-table/m-p/446041#M33270</link>
      <description>&lt;P&gt;@Nadhiyaa while I will be posting a fix with Simple XML JS extension, I would like to point out that there is another option to add icons to table using Unicode characters in Splunk as well. Refer to one of the questions: &lt;A href="https://answers.splunk.com/answers/659050/unicode-characters-in-dashboardssearches.html"&gt;https://answers.splunk.com/answers/659050/unicode-characters-in-dashboardssearches.html&lt;/A&gt;&lt;/P&gt;

&lt;P&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/7257i6A45F1ED390C54B9/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;Following is a run anywhere dashboard example with both options &lt;/P&gt;

&lt;P&gt;Option 1) Using unicode characters in Simple XML Dashboard.&lt;BR /&gt;
Option 2) Using Simple XML JS Extension to add icon to cell on render.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;dashboard script="table_with_icon.js"&amp;gt;
  &amp;lt;label&amp;gt;Check Mark and Cross Using Simple XML&amp;lt;/label&amp;gt;
  &amp;lt;init&amp;gt;
    &amp;lt;!-- Unicode Characters for Check and Cross --&amp;gt;
    &amp;lt;!-- &lt;A href="https://emojipedia.org/heavy-check-mark/" target="test_blank"&gt;https://emojipedia.org/heavy-check-mark/&lt;/A&gt; --&amp;gt;
    &amp;lt;!-- &lt;A href="https://emojipedia.org/cross-mark/" target="test_blank"&gt;https://emojipedia.org/cross-mark/&lt;/A&gt; --&amp;gt;
    &amp;lt;set token="tokCheckGreen"&amp;gt;✔️&amp;lt;/set&amp;gt;
    &amp;lt;set token="tokCrossRed"&amp;gt;❌&amp;lt;/set&amp;gt;
  &amp;lt;/init&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;html depends="$alwaysHideCSSPanel$"&amp;gt;
        &amp;lt;style&amp;gt;
          #tableWithUnicodeIcon td{
            text-align: center;
          }
        &amp;lt;/style&amp;gt;
      &amp;lt;/html&amp;gt;
      &amp;lt;table id="tableWithUnicodeIcon"&amp;gt;
        &amp;lt;title&amp;gt;Table with Unicode Icons (Simple XML)&amp;lt;/title&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;| makeresults count=5
| fields - _time
| streamstats count as sno
| eval Wireless=random(), LAN=random(), None=random()
| eval Wireless=substr(Wireless,1,1),
       LAN=substr(LAN,1,1),
       None=substr(None,1,1)
| eval Wireless=if(Wireless%2==0,"Yes","No"),
       LAN=if((LAN%2)==0,"Yes","No"),
       None=if((None%2)==0,"Yes","No")
| foreach LAN Wireless None 
  [| eval "&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;"=if('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;'=="Yes","$tokCheckGreen$","$tokCrossRed$")]
| table sno *&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;sampleRatio&amp;gt;1&amp;lt;/sampleRatio&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;option name="count"&amp;gt;20&amp;lt;/option&amp;gt;
        &amp;lt;option name="dataOverlayMode"&amp;gt;none&amp;lt;/option&amp;gt;
        &amp;lt;option name="drilldown"&amp;gt;none&amp;lt;/option&amp;gt;
        &amp;lt;option name="percentagesRow"&amp;gt;false&amp;lt;/option&amp;gt;
        &amp;lt;option name="rowNumbers"&amp;gt;false&amp;lt;/option&amp;gt;
        &amp;lt;option name="totalsRow"&amp;gt;false&amp;lt;/option&amp;gt;
        &amp;lt;option name="wrap"&amp;gt;true&amp;lt;/option&amp;gt;
      &amp;lt;/table&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;html depends="$alwaysHideCSSPanel$"&amp;gt;
        &amp;lt;style&amp;gt;
          #tableWithJSIcon td.icon {
              text-align: center;
          }
          #tableWithJSIcon td.icon i {
              font-size: 25px;
              text-shadow: 1px 1px #aaa;
          }
          #tableWithJSIcon td.icon .No {
              color: red;
          }
          #tableWithJSIcon td.icon .Yes {
              color: #006400;
          }
        &amp;lt;/style&amp;gt;
      &amp;lt;/html&amp;gt;
      &amp;lt;table id="tableWithJSIcon"&amp;gt;
        &amp;lt;title&amp;gt;Table with JS Icon&amp;lt;/title&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;| makeresults count=5
| fields - _time
| streamstats count as sno
| eval Wireless=random(), LAN=random(), None=random()
| eval Wireless=substr(Wireless,1,1),
       LAN=substr(LAN,1,1),
       None=substr(None,1,1)
| eval Wireless=if(Wireless%2==0,"Yes","No"),
       LAN=if((LAN%2)==0,"Yes","No"),
       None=if((None%2)==0,"Yes","No")
| table sno *&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;sampleRatio&amp;gt;1&amp;lt;/sampleRatio&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;option name="count"&amp;gt;20&amp;lt;/option&amp;gt;
        &amp;lt;option name="dataOverlayMode"&amp;gt;none&amp;lt;/option&amp;gt;
        &amp;lt;option name="drilldown"&amp;gt;none&amp;lt;/option&amp;gt;
        &amp;lt;option name="percentagesRow"&amp;gt;false&amp;lt;/option&amp;gt;
        &amp;lt;option name="rowNumbers"&amp;gt;false&amp;lt;/option&amp;gt;
        &amp;lt;option name="totalsRow"&amp;gt;false&amp;lt;/option&amp;gt;
        &amp;lt;option name="wrap"&amp;gt;true&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;Following is the JS required for Option 2 as per your Simple XML JS extension approach &lt;CODE&gt;table_with_icon.js&lt;/CODE&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) {
    console.log("Inside Script");
    // Translations from rangemap results to CSS class
    var ICONS = {
        No: 'x-circle',
        Yes: 'check-circle'
    };
    var RangeMapIconRenderer = TableView.BaseCellRenderer.extend({
        canRender: function (cell) {
            // Only use the cell renderer for the range field
            return _(["Wireless", "LAN", "None"]).contains(cell.field);
        },
        render: function ($td, cell) {
            var icon = 'question';
            // Fetch the icon for the value
            if (ICONS.hasOwnProperty(cell.value)) {
                icon = ICONS[cell.value];
            }
            // Create the icon element and add it to the table cell
            $td.addClass('icon').html(_.template('&amp;lt;i class="icon-&amp;lt;%-icon%&amp;gt; &amp;lt;%- range %&amp;gt; title="&amp;lt;%- range %&amp;gt;"&amp;gt;&amp;lt;/i&amp;gt;', {
                icon: icon,
                range: cell.value
            }));
        }
    });
    mvc.Components.get('tableWithJSIcon').getVisualization(function (tableView) {
        // Register custom cell renderer, the table will re-render automatically
        tableView.addCellRenderer(new RangeMapIconRenderer());
    });
});
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 30 Jun 2019 14:57:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-icons-for-the-multiple-fields-in-splunk-table/m-p/446041#M33270</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2019-06-30T14:57:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to add icons for the multiple fields in splunk table</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-icons-for-the-multiple-fields-in-splunk-table/m-p/446042#M33271</link>
      <description>&lt;P&gt;@Nadhiyaa could you please confirm whether one of above options worked for you or not?&lt;/P&gt;</description>
      <pubDate>Tue, 14 Apr 2020 02:49:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-icons-for-the-multiple-fields-in-splunk-table/m-p/446042#M33271</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2020-04-14T02:49:32Z</dc:date>
    </item>
  </channel>
</rss>

