Dashboards & Visualizations

applying a css style to a single element

cphair
Builder

This is probably a simple one, but I'm a novice at CSS. I have an advanced XML dashboard with several tables, and I need to apply a custom style to one of them. The code just affects the td elements, so the current CSS declaration is td.myCustomClass {blah blah}. I tested the code on a sample dashboard and it works, but I don't know how to scope it to apply to just one table. In straight-up CSS/HTML, I guess I would add an id tag to the single table I want to format differently, and then make my CSS declaration something like td.myCustomClass #foo {blah}. I'm not sure (a) if that's exactly the right CSS syntax, and (b) how I apply an id tag in advanced XML. Am I on the right track?

Tags (3)
1 Solution

cphair
Builder

Based on a couple other answers (such as http://splunk-base.splunk.com/answers/69863/a-quick-question-about-applicationjs ), trying to use an id like I would expect is kind of ugly, because the one Splunk generates in the HTML is based on the type of module and its order in the page. The way I solved my issue was to add group="mygroupname" to the definition of the one table I wanted to change, and then add if (this.getGroupName() != "mygroupname") {return;} to my custom code block in application.js (which I see I didn't mention in my question). The JS code block is already scoped to the particular view I need it for, so hopefully this isn't too inefficient. If anyone has a better way to handle this, I'd be interested to hear it.

View solution in original post

cphair
Builder

Based on a couple other answers (such as http://splunk-base.splunk.com/answers/69863/a-quick-question-about-applicationjs ), trying to use an id like I would expect is kind of ugly, because the one Splunk generates in the HTML is based on the type of module and its order in the page. The way I solved my issue was to add group="mygroupname" to the definition of the one table I wanted to change, and then add if (this.getGroupName() != "mygroupname") {return;} to my custom code block in application.js (which I see I didn't mention in my question). The JS code block is already scoped to the particular view I need it for, so hopefully this isn't too inefficient. If anyone has a better way to handle this, I'd be interested to hear it.

kasu_praveen
Communicator

Thanks cphair. "this.getGroupName()" is perfectly working.

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...