Dashboards & Visualizations

how to change the width of a column in a table?

anooshac
Communicator

Hi All, i am trying reduce the width of 2nd and 3rd column of a table since some of the cell has big sentence and it occupies too much space.

i tried referring an example like below.

<row>
    <panel>
      <html depends="$alwaysHideCSSPanel$">
        <style>
          #tableColumWidth table thead tr th:nth-child(2),
          #tableColumWidth table thead tr th:nth-child(3){
            width: 10% !important;
            overflow-wrap: anywhere !important;
          }          
        </style>
      </html>
      <table id="tableColumWidth">

 

But i am not able to change the width using this. Any corrections needed in above html?

Labels (2)
Tags (4)
0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

@anooshac 

Can you please try this sample code? 

Please observe 2nd column width.

<dashboard version="1.1" theme="dark">
  <label>table column size</label>
  <row>
    <panel>
      <table id="tableColumWidth">
        <search>
          <query>|makeresults count=5 | eval A=random(), B=random(), status=A, action=A</query>
          <earliest>-24h@h</earliest>
          <latest>now</latest>
        </search>
        <option name="drilldown">none</option>
      </table>
    </panel>
  </row>
  <row>
    <panel>
      <html>
        <style>
          
          #tableColumWidth table th:nth-child(2),
          #tableColumWidth table td:nth-child(2) {
            width: 1000px !important;
            overflow-wrap: anywhere !important;
        }
        </style>
      </html>
    </panel>
  </row>
</dashboard>

 

Screenshot 2024-06-03 at 11.49.08 AM.png

I hope this will help you.

 

Thanks
KV
An upvote would be appreciated if any of my replies help you solve the problem or gain knowledge.

0 Karma

anooshac
Communicator

Hi @kamlesh_vaghela , tried this but the dashboard width isn't changing.

0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

@anooshac 

Can you please share your full sample code?

KV

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @anooshac ,

if you see in the Splunk Dashboard Examples app (https://splunkbase.splunk.com/app/1603 ) there's exactly  also this example.

Ciao.

Giuseppe

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

The problem with tables is that the browser(?) tries to adjust the table after the CSS, which usually overrides whatever width you have tried to set.

0 Karma

anooshac
Communicator

@ITWhisperer,so there is no solution for changing width?

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

It depends on what it is you are trying to achieve and what you would accept as a "solution". For example, you could try adding spaces to the end of field names so the column width increases. Basically, it is a lot of trial and error to get something close to what you want, and you might not get there, so perhaps you should ask yourself, is it worth the effort?

0 Karma
Get Updates on the Splunk Community!

Technical Workshop Series: Splunk Data Management and SPL2 | Register here!

Hey, Splunk Community! Ready to take your data management skills to the next level? Join us for a 3-part ...

Spotting Financial Fraud in the Haystack: A Guide to Behavioral Analytics with Splunk

In today's digital financial ecosystem, security teams face an unprecedented challenge. The sheer volume of ...

Solve Problems Faster with New, Smarter AI and Integrations in Splunk Observability

Solve Problems Faster with New, Smarter AI and Integrations in Splunk Observability As businesses scale ...