Dashboards & Visualizations

displaying odd row as black color and even row as white color in simple table results module using application.js and css file

madanashok
Path Finder

Hi Splunkers,

I would feel great if somebody help me to display the table results with even row in one color and
odd row in one color using simple results table module.

Tags (1)
0 Karma

sideview
SplunkTrust
SplunkTrust

The approach suggested by jonuwz that uses the :nth-child CSS selector will work on newer browsers just fine. If you want a simple solution that will work even on older browsers though, here's an extra option.

Download and install the latest Sideview Utils and use the sideview Table module.

Then add some search language, either on the end of your base search or using a PostProcess module:

If you tacked on some search language like so:

 | streamstats count | eval evenOrOdd=if(isint(count/2),"even","odd")

That will give each row a field called evenOrOdd, that will be either "even" or "odd". Then you can use the Table module's rowClass param to specify that this field should be used as the classname. Additionally we'll use the hiddenFields param to specify that the evenOrOdd field should not actually appear in the rendered table.

<module name="Table">
  <param name="rowClass">$row.fields.evenOrOdd$</param>
  <param name="hiddenFields">evenOrOdd</param>

Last but not least, you would just add this simple custom CSS to specify the two colors:

.Table tr.even td {
    background-color:#eeeeee;
}
.Table tr.odd td {
    background-color:#cccccc;
}
0 Karma

bmacias84
Champion

There is a cool app on Splunk Base called rowcolorizer. This should do what you want and more.

Hope this helps.

robertpa
Engager

I downvoted this post because this is a dead link.

0 Karma

jonuwz
Influencer

You don't really need application.js ( if you're using a fairly recent browser )

Just put this in application.css - you'll need to restart unless application.js already exists :

tr:nth-child(2n) {
     background: none repeat scroll 0% 0% #000000;
}

tr:nth-child(2n) td {
    color: #DDDDDD;
}

abulco01
Explorer

This worked perfectly! Thank you so much!

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Take Action Automatically on Splunk Alerts with Red Hat Ansible Automation Platform

 Are you ready to revolutionize your IT operations? As digital transformation accelerates, the demand for ...

Calling All Security Pros: Ready to Race Through Boston?

Hey Splunkers, .conf25 is heading to Boston and we’re kicking things off with something bold, competitive, and ...

Beyond Detection: How Splunk and Cisco Integrated Security Platforms Transform ...

Financial services organizations face an impossible equation: maintain 99.9% uptime for mission-critical ...