<?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 color lines in a table by clicking a cell? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-color-lines-in-a-table-by-clicking-a-cell/m-p/221910#M65234</link>
    <description>&lt;P&gt;How can I just border the table in dashboard panel ? I doesn't want color on click of a cell..&lt;/P&gt;</description>
    <pubDate>Thu, 06 Jun 2019 18:44:24 GMT</pubDate>
    <dc:creator>rashi83</dc:creator>
    <dc:date>2019-06-06T18:44:24Z</dc:date>
    <item>
      <title>How to color lines in a table by clicking a cell?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-color-lines-in-a-table-by-clicking-a-cell/m-p/221906#M65230</link>
      <description>&lt;P&gt;Hi everybody&lt;/P&gt;

&lt;P&gt;I want to know how I can color the all the lines in my table by clicking on a cell.&lt;BR /&gt;
I tried this code and the message on console works fine, but the coloration doesn't and I don't understand why:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;%css&amp;gt;
#highlight tr.range-mine td{
color:red;
}
&amp;lt;%css&amp;gt;


&amp;lt;%javascript&amp;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 _(['id']).contains(cell.field);
        },
        render: function($td,cell) {
            var value = String(cell.value); 
if(cell.field === 'id'){

$td.on('click',function(){

console.log('td',value);
$td.addClass('range-cell').addClass('range-mine');
});

}
        $td.text(value.split(";")[0]).addClass('text');

        }
    });

    mvc.Components.get('highlight').getVisualization(function(tableView){
        tableView.table.addCellRenderer(new CustomRangeRenderer());
            tableView.on('rendered',function(){
            tableView.$el.find('td.range-cell').each(function(){
            $(this).parents('tr').addClass(this.className);
             });
            });
        tableView.table.render();
    });  

});
&amp;lt;%javascript&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;thx&lt;/P&gt;</description>
      <pubDate>Tue, 15 Sep 2015 09:54:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-color-lines-in-a-table-by-clicking-a-cell/m-p/221906#M65230</guid>
      <dc:creator>sfatnass</dc:creator>
      <dc:date>2015-09-15T09:54:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to color lines in a table by clicking a cell?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-color-lines-in-a-table-by-clicking-a-cell/m-p/221907#M65231</link>
      <description>&lt;P&gt;no body have any idea?&lt;/P&gt;</description>
      <pubDate>Thu, 17 Sep 2015 07:50:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-color-lines-in-a-table-by-clicking-a-cell/m-p/221907#M65231</guid>
      <dc:creator>sfatnass</dc:creator>
      <dc:date>2015-09-17T07:50:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to color lines in a table by clicking a cell?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-color-lines-in-a-table-by-clicking-a-cell/m-p/221908#M65232</link>
      <description>&lt;P&gt;The easiest way to color ALL the table cells would be to set class for all td elements on click using jquery ('td') selector.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;style&amp;gt;
    .red {
        color: red !important
    }
&amp;lt;/style&amp;gt;

&amp;lt;script&amp;gt;
    // listen for clicks only on first column
    var CustomCellRenderer = TableView.BaseCellRenderer.extend({
        canRender: function(cellData) {
            return cellData.index === 0;
        },

        render: function($td, cellData) {
            value = cellData.value;

            $td.on('click', function() {
                    $('td').addClass('red');
                })

            $td.text(value);
        }

    });
&amp;lt;/script&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;To color only one line (parent tr) use:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;        $td.on('click', function() {
                $td.parent().addClass('red');
            })
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 01 Oct 2015 10:23:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-color-lines-in-a-table-by-clicking-a-cell/m-p/221908#M65232</guid>
      <dc:creator>piUek</dc:creator>
      <dc:date>2015-10-01T10:23:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to color lines in a table by clicking a cell?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-color-lines-in-a-table-by-clicking-a-cell/m-p/221909#M65233</link>
      <description>&lt;P&gt;i solved it, using function js within my html dashboard.&lt;/P&gt;

&lt;P&gt;=&amp;gt;&amp;gt; if click on line push value in array and send array content to color function.&lt;/P&gt;

&lt;P&gt;if click again on same line (detected by an id), splice this value from array and resend the new array content to refresh automatic the color.&lt;/P&gt;

&lt;P&gt;^^&lt;/P&gt;

&lt;P&gt;thx again&lt;/P&gt;</description>
      <pubDate>Thu, 01 Oct 2015 12:44:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-color-lines-in-a-table-by-clicking-a-cell/m-p/221909#M65233</guid>
      <dc:creator>sfatnass</dc:creator>
      <dc:date>2015-10-01T12:44:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to color lines in a table by clicking a cell?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-color-lines-in-a-table-by-clicking-a-cell/m-p/221910#M65234</link>
      <description>&lt;P&gt;How can I just border the table in dashboard panel ? I doesn't want color on click of a cell..&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jun 2019 18:44:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-color-lines-in-a-table-by-clicking-a-cell/m-p/221910#M65234</guid>
      <dc:creator>rashi83</dc:creator>
      <dc:date>2019-06-06T18:44:24Z</dc:date>
    </item>
  </channel>
</rss>

