<?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: Advanced XML - Highlight certain values in a table (not numerical) in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Advanced-XML-Highlight-certain-values-in-a-table-not-numerical/m-p/94463#M24363</link>
    <description>&lt;P&gt;Yes, through the power of JavaScript!!&lt;/P&gt;

&lt;P&gt;Put this in application.js in appserver/static folder of your app.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;if ((Splunk.util.getCurrentView() == "YOURDASHBOARDXMLNAME") &amp;amp;&amp;amp; Splunk.Module.SimpleResultsTable) {
    Splunk.Module.SimpleResultsTable = $.klass(Splunk.Module.SimpleResultsTable, {
        onResultsRendered: function($super) {
            var retVal = $super();
            this.myCustomHeatMapDecorator();
            return retVal;
        },
    myCustomHeatMapDecorator: function() {
            $("tr:has(td)", this.container).each(function() {
                var tr = $(this);
                if (tr.find("td:nth-child(3)").text() == "passed") {
                    tr.addClass("passedClass");
                }
                if (tr.find("td:nth-child(3)").text() == "failed") {
                    tr.addClass("failedClass");
                }
            });
        },
    });
}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Just to be clear about, &lt;CODE&gt;td:nth-child(3)&lt;/CODE&gt;. Basically I am assuming you have row numbering at the left of the table, this is actually part of the table and TD in a TR is numbered sequentially from 1 so the row numbers are &lt;CODE&gt;td:nth-child(1)&lt;/CODE&gt; and that makes your passed/failed column number 3. If you didn't have the row numbers then it would be &lt;CODE&gt;td:nth-child(2)&lt;/CODE&gt; you need.&lt;/P&gt;

&lt;P&gt;Then some CSS gubbins (application.css);&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;tr.failedClass td {
    background-color:#000000 !important;
    color: #FFFFFF !important;
}

tr.passedClass td {
    background-color:#FFFFFF !important;
    color: #000000 !important;
}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Props to Nick for this, however I can't find/remember where I first discovered this &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; If you want you can remove the comparison to the current view name if you just want this to be applied to all third cells across your app.&lt;/P&gt;</description>
    <pubDate>Fri, 16 Mar 2012 09:31:49 GMT</pubDate>
    <dc:creator>Drainy</dc:creator>
    <dc:date>2012-03-16T09:31:49Z</dc:date>
    <item>
      <title>Advanced XML - Highlight certain values in a table (not numerical)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Advanced-XML-Highlight-certain-values-in-a-table-not-numerical/m-p/94462#M24362</link>
      <description>&lt;P&gt;Hi Splunkbase,&lt;/P&gt;

&lt;P&gt;I was just wondering how I would go about highlighting a certain value in my table on a dashboard (e.g. "failed"). This is a realtime dashboard, and I need to highlight the value when it's state is "failed"... the following is an example of the table.&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;device         state&lt;BR /&gt;
192.168.0.1    passed&lt;BR /&gt;
192.168.0.2    failed&lt;BR /&gt;
192.168.2.3    passed&lt;BR /&gt;
192.168.2.4    passed&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;So in this example I would like to highlight the "state" value for "192.168.0.2" (possibly the entire row).&lt;/P&gt;

&lt;P&gt;Can this be done, if so how?&lt;/P&gt;

&lt;P&gt;Regards,&lt;/P&gt;

&lt;P&gt;MHibbin&lt;/P&gt;

&lt;P&gt;EDIT: updated JS script for IE issues (e.g. with unused ",")&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;if ((Splunk.util.getCurrentView() === "YOURDASHBOARDXMLNAME") &amp;amp;&amp;amp; Splunk.Module.SimpleResultsTable) {
    Splunk.Module.SimpleResultsTable = $.klass(Splunk.Module.SimpleResultsTable, {
        onResultsRendered: function ($super) {
            var retVal = $super();
            this.myCustomHeatMapDecorator();
            return retVal;
        },
        myCustomHeatMapDecorator: function () {
            $("tr:has(td)", this.container).each(function () {
                var tr = $(this);
                if (tr.find("td:nth-child(3)").text() === "passed") {
                    tr.addClass("passedClass");
                }
                if (tr.find("td:nth-child(3)").text() === "failed") {
                    tr.addClass("failedClass");
                }
            });
        }
    });
}
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 16 Mar 2012 08:50:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Advanced-XML-Highlight-certain-values-in-a-table-not-numerical/m-p/94462#M24362</guid>
      <dc:creator>MHibbin</dc:creator>
      <dc:date>2012-03-16T08:50:40Z</dc:date>
    </item>
    <item>
      <title>Re: Advanced XML - Highlight certain values in a table (not numerical)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Advanced-XML-Highlight-certain-values-in-a-table-not-numerical/m-p/94463#M24363</link>
      <description>&lt;P&gt;Yes, through the power of JavaScript!!&lt;/P&gt;

&lt;P&gt;Put this in application.js in appserver/static folder of your app.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;if ((Splunk.util.getCurrentView() == "YOURDASHBOARDXMLNAME") &amp;amp;&amp;amp; Splunk.Module.SimpleResultsTable) {
    Splunk.Module.SimpleResultsTable = $.klass(Splunk.Module.SimpleResultsTable, {
        onResultsRendered: function($super) {
            var retVal = $super();
            this.myCustomHeatMapDecorator();
            return retVal;
        },
    myCustomHeatMapDecorator: function() {
            $("tr:has(td)", this.container).each(function() {
                var tr = $(this);
                if (tr.find("td:nth-child(3)").text() == "passed") {
                    tr.addClass("passedClass");
                }
                if (tr.find("td:nth-child(3)").text() == "failed") {
                    tr.addClass("failedClass");
                }
            });
        },
    });
}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Just to be clear about, &lt;CODE&gt;td:nth-child(3)&lt;/CODE&gt;. Basically I am assuming you have row numbering at the left of the table, this is actually part of the table and TD in a TR is numbered sequentially from 1 so the row numbers are &lt;CODE&gt;td:nth-child(1)&lt;/CODE&gt; and that makes your passed/failed column number 3. If you didn't have the row numbers then it would be &lt;CODE&gt;td:nth-child(2)&lt;/CODE&gt; you need.&lt;/P&gt;

&lt;P&gt;Then some CSS gubbins (application.css);&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;tr.failedClass td {
    background-color:#000000 !important;
    color: #FFFFFF !important;
}

tr.passedClass td {
    background-color:#FFFFFF !important;
    color: #000000 !important;
}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Props to Nick for this, however I can't find/remember where I first discovered this &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; If you want you can remove the comparison to the current view name if you just want this to be applied to all third cells across your app.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Mar 2012 09:31:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Advanced-XML-Highlight-certain-values-in-a-table-not-numerical/m-p/94463#M24363</guid>
      <dc:creator>Drainy</dc:creator>
      <dc:date>2012-03-16T09:31:49Z</dc:date>
    </item>
    <item>
      <title>Re: Advanced XML - Highlight certain values in a table (not numerical)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Advanced-XML-Highlight-certain-values-in-a-table-not-numerical/m-p/94464#M24364</link>
      <description>&lt;P&gt;@Drainy, &lt;/P&gt;

&lt;P&gt;Just thought I would update this, as I have used it quite a bit actually (nice bit of code). However there were some issues running it on IE8. So I ran it through JSLint (&lt;A href="http://jslint.com/"&gt;http://jslint.com/&lt;/A&gt;) and corrected what JSLint thought were errors. Just wanted to check you agreed really... (see above for amendments.&lt;/P&gt;

&lt;P&gt;Cheers,&lt;/P&gt;

&lt;P&gt;MHibbin&lt;/P&gt;</description>
      <pubDate>Wed, 11 Jul 2012 11:47:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Advanced-XML-Highlight-certain-values-in-a-table-not-numerical/m-p/94464#M24364</guid>
      <dc:creator>MHibbin</dc:creator>
      <dc:date>2012-07-11T11:47:04Z</dc:date>
    </item>
    <item>
      <title>Re: Advanced XML - Highlight certain values in a table (not numerical)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Advanced-XML-Highlight-certain-values-in-a-table-not-numerical/m-p/94465#M24365</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;
I have trying to do this, but my application.js does not get called for some reason.&lt;BR /&gt;
I have created both the .js &amp;amp; .css files.&lt;BR /&gt;
Is there any other changes i need to do in order to get this working.&lt;/P&gt;

&lt;P&gt;I am new to Splunk, any help would be great.&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 27 Sep 2012 18:06:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Advanced-XML-Highlight-certain-values-in-a-table-not-numerical/m-p/94465#M24365</guid>
      <dc:creator>alenseb</dc:creator>
      <dc:date>2012-09-27T18:06:09Z</dc:date>
    </item>
    <item>
      <title>Re: Advanced XML - Highlight certain values in a table (not numerical)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Advanced-XML-Highlight-certain-values-in-a-table-not-numerical/m-p/94466#M24366</link>
      <description>&lt;P&gt;This is my requirement, i need to color the column according to the column2 values.&lt;/P&gt;

&lt;P&gt;column1      column2&lt;BR /&gt;
198.168.0.1    green&lt;BR /&gt;
198.168.0.1    red&lt;BR /&gt;
198.168.0.1    blue&lt;BR /&gt;
This the code i am using:&lt;BR /&gt;
  myCustomHeatMapDecorator: function() {&lt;BR /&gt;
            $("tr:has(td)", this.container).each(function() {&lt;BR /&gt;
var tr = $(this);if (tr.find("td:nth-child(3)").text() == "green") {tr.addClass("clsGreen");}&lt;BR /&gt;
                if (tr.find("td:nth-child(3)").text() == "red") {tr.addClass("clsRed");&lt;BR /&gt;
                }&lt;BR /&gt;
                if (tr.find("td:nth-child(4)").text() == "blue") {      tr.addClass("clsBlue");});&lt;/P&gt;</description>
      <pubDate>Thu, 27 Sep 2012 18:15:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Advanced-XML-Highlight-certain-values-in-a-table-not-numerical/m-p/94466#M24366</guid>
      <dc:creator>alenseb</dc:creator>
      <dc:date>2012-09-27T18:15:41Z</dc:date>
    </item>
    <item>
      <title>Re: Advanced XML - Highlight certain values in a table (not numerical)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Advanced-XML-Highlight-certain-values-in-a-table-not-numerical/m-p/94467#M24367</link>
      <description>&lt;P&gt;This problem got solved! &lt;BR /&gt;
I had to create Home.xml and few settings.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Sep 2012 07:31:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Advanced-XML-Highlight-certain-values-in-a-table-not-numerical/m-p/94467#M24367</guid>
      <dc:creator>alenseb</dc:creator>
      <dc:date>2012-09-28T07:31:06Z</dc:date>
    </item>
    <item>
      <title>Re: Advanced XML - Highlight certain values in a table (not numerical)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Advanced-XML-Highlight-certain-values-in-a-table-not-numerical/m-p/94468#M24368</link>
      <description>&lt;P&gt;As a tiny side note:   the Table module coming out in Sideview Utils 2.2 will be able to do this quite easily.   There is a param called 'classField', which in this case you would set like so:  &lt;CODE&gt;&amp;lt;param name="classField"&amp;gt;$row.state$&amp;lt;/param&amp;gt;&lt;/CODE&gt;  And then you would define CSS classnames for the background colors.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Sep 2012 07:35:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Advanced-XML-Highlight-certain-values-in-a-table-not-numerical/m-p/94468#M24368</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2012-09-28T07:35:57Z</dc:date>
    </item>
    <item>
      <title>Re: Advanced XML - Highlight certain values in a table (not numerical)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Advanced-XML-Highlight-certain-values-in-a-table-not-numerical/m-p/94469#M24369</link>
      <description>&lt;P&gt;@sideview, when are you planning to release v2.2? - will it follow the same licensing model as the current release? - i.e. a paid for product - or will you release an updated free version (as in the version available on SB)&lt;/P&gt;</description>
      <pubDate>Fri, 28 Sep 2012 08:27:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Advanced-XML-Highlight-certain-values-in-a-table-not-numerical/m-p/94469#M24369</guid>
      <dc:creator>MHibbin</dc:creator>
      <dc:date>2012-09-28T08:27:13Z</dc:date>
    </item>
    <item>
      <title>Re: Advanced XML - Highlight certain values in a table (not numerical)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Advanced-XML-Highlight-certain-values-in-a-table-not-numerical/m-p/94470#M24370</link>
      <description>&lt;P&gt;2.2 should come out in a few weeks depending on some scheduling.  Note that the current release is free for internal use.  That change happened several months ago.  Go to the site ( &lt;A href="http://sideviewapps.com/apps/sideview-utils/"&gt;http://sideviewapps.com/apps/sideview-utils/&lt;/A&gt; ) and click "download full version (internal use only)".   For a brief time right after 2.0 launched I tried a model  where I charged for basic use.  Anyway, you should upgrade because I've been busy and the 1.3.X version on Splunkbase dates from something like Feburuary or March of this year. Ancient!&lt;/P&gt;</description>
      <pubDate>Fri, 28 Sep 2012 15:39:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Advanced-XML-Highlight-certain-values-in-a-table-not-numerical/m-p/94470#M24370</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2012-09-28T15:39:07Z</dc:date>
    </item>
    <item>
      <title>Re: Advanced XML - Highlight certain values in a table (not numerical)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Advanced-XML-Highlight-certain-values-in-a-table-not-numerical/m-p/94471#M24371</link>
      <description>&lt;P&gt;&lt;A href="http://sideviewapps.com/apps/sideview-utils/"&gt;Sideview Utils 2.2&lt;/A&gt; came out recently, and with it came the Sideview Table module.    With the Table module, this sort of thing becomes dead simple. &lt;/P&gt;

&lt;P&gt;If you have a field called "state" whose values are "passed" and "failed",  then here's your Table: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;module name="Table"&amp;gt;
  &amp;lt;param name="rowClass"&amp;gt;$row.fields.state$&amp;lt;/param&amp;gt;      
&amp;lt;/module&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The second piece is the CSS.  Put this into application.css, or put it into a custom CSS file referenced by the stylesheet attribute in your view,  or use an HTML module to embed it right into the page inside a &lt;CODE&gt;&amp;lt;style type="text/css"&amp;gt;&lt;/CODE&gt; tag: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;.Table tr.passed td {
    background-color:#d7efff;
}
.Table tr.failed td {
    background-color:#d93c3c;
    color:#fff;
}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and the third piece is optional - &lt;EM&gt;if&lt;/EM&gt; you dont want the 'state' field to actually be visible in the Table,  you can also add state to the "hiddenFields" param, like so: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;module name="Table"&amp;gt;
  &amp;lt;param name="rowClass"&amp;gt;$row.fields.state$&amp;lt;/param&amp;gt;
  &amp;lt;param name="hiddenFields"&amp;gt;state&amp;lt;/param&amp;gt;
&amp;lt;/module&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Note that you can download Sideview Utils 2.2 only from the &lt;A href="http://sideviewapps.com/apps/sideview-utils/"&gt;Sideview website&lt;/A&gt; &lt;/P&gt;</description>
      <pubDate>Tue, 09 Oct 2012 20:11:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Advanced-XML-Highlight-certain-values-in-a-table-not-numerical/m-p/94471#M24371</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2012-10-09T20:11:23Z</dc:date>
    </item>
  </channel>
</rss>

