Dashboards & Visualizations

Colouring Table cells based on the table ID and Cell Value

ahallak2016
Explorer

Hi all,

I would like to color table cells based on the table ID and the cell values. The only examples that I have found on splunk answers involve checking what the cell.field is first before checking the values, but in my case this wont be possible because the field names returned may be different with each search. Furthermore, different tables will have the exact same field names but will always have different coloring rules (thresholds).

Is there a way to color the table cells by first checking what the table ID is and then checking the values?

This is what I would like to do (notice how i would like to check what the table id is in the if statement, instead of checking what the cell.field is?):

var val = cell.value;
var split_val = val.split("%")[0];
var value = parseFloat(split_val); 

if ({table id} == 'some value') 
{
      if (value >= 50.0) 
     {
       $td.addClass('Green');
     }
     else
     {
        $td.addClass('Red');
     }
}
if ({table id} == 'another value') 
{
      if (value >= 70.0) 
     {
       $td.addClass('Green');
     }
     else
     {
        $td.addClass('Red');
     }
}
Tags (1)
0 Karma
1 Solution

rjthibod
Champion

I am pretty sure the answer is no, you cannot do what you ask.

My understanding is the coding pattern dictates that you must add a cell rendering callback (via addCellRenderer()) for the table instance, but the callback function does not get the table ID when it is called. So you can create multiple callback functions (i.e., a unique callback for each table), and then apply your thresholds accordingly.

View solution in original post

niketn
Legend

If you upgrade to 6.5 or higher you will have cell coloring option built in to the table. Without JS/CSS extension.

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma

rjthibod
Champion

I am pretty sure the answer is no, you cannot do what you ask.

My understanding is the coding pattern dictates that you must add a cell rendering callback (via addCellRenderer()) for the table instance, but the callback function does not get the table ID when it is called. So you can create multiple callback functions (i.e., a unique callback for each table), and then apply your thresholds accordingly.

ahallak2016
Explorer

Ahh thanks for the reply.

I eventually found a work around by creating a separate JS file for each table. Its not a very elegant solutions but it will suffice for the time being.

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Index This | What travels the world but is also stuck in place?

April 2026 Edition  Hayyy Splunk Education Enthusiasts and the Eternally Curious!   We’re back with this ...

Discover New Use Cases: Unlock Greater Value from Your Existing Splunk Data

Realizing the full potential of your Splunk investment requires more than just understanding current usage; it ...

Continue Your Journey: Join Session 2 of the Data Management and Federation Bootcamp ...

As data volumes continue to grow and environments become more distributed, managing and optimizing data ...