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
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 ...