<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to add a header for row numbers in a column in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-a-header-for-row-numbers-in-a-column/m-p/482867#M31653</link>
    <description>&lt;P&gt;kamlesh_vaghela,&lt;BR /&gt;
     thank you very much, It's the answer I want，But there was a problem refreshing the page， is there any other method except setTimeout call? &lt;BR /&gt;
   why change your code like this do not work?&lt;BR /&gt;
 require(["jquery", "splunkjs/mvc", "splunkjs/mvc/simplexml/ready!"], function($, mvc) {&lt;BR /&gt;&lt;BR /&gt;
     $(function() {&lt;BR /&gt;
         $('div[id^="mytable2-"]').find($("th.row-number")).html("My Header");&lt;BR /&gt;
     });&lt;BR /&gt;
 });&lt;/P&gt;</description>
    <pubDate>Wed, 13 Nov 2019 13:17:26 GMT</pubDate>
    <dc:creator>zzjcfj</dc:creator>
    <dc:date>2019-11-13T13:17:26Z</dc:date>
    <item>
      <title>How to add a header for row numbers in a column</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-a-header-for-row-numbers-in-a-column/m-p/482863#M31649</link>
      <description>&lt;P&gt;I have set a column for row numbers in the table view of the dashboard like this figure, but I want to have a header. &lt;BR /&gt;
How can I change the blank header like the simple_xml_examples  with javascript change the rows?&lt;/P&gt;

&lt;P&gt;&lt;IMG src="https://community.splunk.com/storage/temp/275133-rowsnumber-header.png" alt="alt text" /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 02:57:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-a-header-for-row-numbers-in-a-column/m-p/482863#M31649</guid>
      <dc:creator>zzjcfj</dc:creator>
      <dc:date>2020-09-30T02:57:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a header for row numbers in a column</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-a-header-for-row-numbers-in-a-column/m-p/482864#M31650</link>
      <description>&lt;P&gt;Instead of using the table view feature to switch on row numbers, you could add a streamstats to count after your search, eg&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;your search&amp;gt; | streamstats count as "your label" | table "your label", _time, count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That should do it without further magic, if I correctly understood what you asked for.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Nov 2019 09:15:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-a-header-for-row-numbers-in-a-column/m-p/482864#M31650</guid>
      <dc:creator>knielsen</dc:creator>
      <dc:date>2019-11-13T09:15:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a header for row numbers in a column</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-a-header-for-row-numbers-in-a-column/m-p/482865#M31651</link>
      <description>&lt;P&gt;@zzjcfj &lt;/P&gt;

&lt;P&gt;Not clear about the question but I think you want to replace BLANK header with some value OR need result count. Well, can you please try below example ??&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;XML:&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;dashboard script="status.js"&amp;gt;
  &amp;lt;label&amp;gt;Test&amp;lt;/label&amp;gt;
  &amp;lt;row&amp;gt;
     &amp;lt;panel&amp;gt;
      &amp;lt;table id="mytable2"&amp;gt;
        &amp;lt;title&amp;gt;$row_count$&amp;lt;/title&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;index="_internal" | stats count by sourcetype&amp;lt;/query&amp;gt;
          &amp;lt;earliest&amp;gt;-4h@m&amp;lt;/earliest&amp;gt;
          &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
          &amp;lt;done&amp;gt;
            &amp;lt;set token="row_count"&amp;gt;$job.resultCount$&amp;lt;/set&amp;gt;
          &amp;lt;/done&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;option name="drilldown"&amp;gt;none&amp;lt;/option&amp;gt;
        &amp;lt;option name="rowNumbers"&amp;gt;true&amp;lt;/option&amp;gt;
      &amp;lt;/table&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
&amp;lt;/dashboard&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;Javascript:&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;require(["jquery", "splunkjs/mvc", "splunkjs/mvc/simplexml/ready!"], function($, mvc) { 
    $(function() {
        var myVar = setTimeout(function() {
            $('div[id^="mytable2-"]').find($("th.row-number")).html("My Header");
            clearTimeout(myVar);
        }, 2000);

    });
});
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 13 Nov 2019 10:02:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-a-header-for-row-numbers-in-a-column/m-p/482865#M31651</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2019-11-13T10:02:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a header for row numbers in a column</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-a-header-for-row-numbers-in-a-column/m-p/482866#M31652</link>
      <description>&lt;P&gt;@knielsen thank you for your answer, it is work fine &lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/7944iC47E95E5671F5334/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Nov 2019 12:42:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-a-header-for-row-numbers-in-a-column/m-p/482866#M31652</guid>
      <dc:creator>zzjcfj</dc:creator>
      <dc:date>2019-11-13T12:42:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a header for row numbers in a column</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-a-header-for-row-numbers-in-a-column/m-p/482867#M31653</link>
      <description>&lt;P&gt;kamlesh_vaghela,&lt;BR /&gt;
     thank you very much, It's the answer I want，But there was a problem refreshing the page， is there any other method except setTimeout call? &lt;BR /&gt;
   why change your code like this do not work?&lt;BR /&gt;
 require(["jquery", "splunkjs/mvc", "splunkjs/mvc/simplexml/ready!"], function($, mvc) {&lt;BR /&gt;&lt;BR /&gt;
     $(function() {&lt;BR /&gt;
         $('div[id^="mytable2-"]').find($("th.row-number")).html("My Header");&lt;BR /&gt;
     });&lt;BR /&gt;
 });&lt;/P&gt;</description>
      <pubDate>Wed, 13 Nov 2019 13:17:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-a-header-for-row-numbers-in-a-column/m-p/482867#M31653</guid>
      <dc:creator>zzjcfj</dc:creator>
      <dc:date>2019-11-13T13:17:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a header for row numbers in a column</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-a-header-for-row-numbers-in-a-column/m-p/482868#M31654</link>
      <description>&lt;P&gt;@zzjcfj I think @kamlesh_vaghela jumped the gun and applied jQuery update to dashboard load setTimeout rather than table render setTimeout. The solution that you need requires Table Render extension through SplunkJS. Please refer to one of my older answers on similar lines: &lt;A href="https://answers.splunk.com/answers/515162/how-can-i-add-a-summary-row-to-a-table-in-simple-x.html"&gt;https://answers.splunk.com/answers/515162/how-can-i-add-a-summary-row-to-a-table-in-simple-x.html&lt;/A&gt;&lt;BR /&gt;
*&lt;EM&gt;You will have to scroll down to the answer which is not accepted &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt; *&lt;/EM&gt;&lt;/P&gt;

&lt;P&gt;If you extend the table render through JS you will avoid adding &lt;CODE&gt;streamstats&lt;/CODE&gt; in your existing query &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;Following is the complete run anywhere example based on Splunk's _internal index as per your question (use case) to show a label &lt;CODE&gt;Row #&lt;/CODE&gt; (customizable through JS extension). This should be able to handle table re-render, refresh etc as it extends table render.&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/7945i69246768C1E67F94/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;Following is the required Simple XML code:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;dashboard script="table_row_number_header_extension.js"&amp;gt;
  &amp;lt;label&amp;gt;Table with Serial Number Header&amp;lt;/label&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;table id="tableWithRowNumAndHeader"&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;index=_internal sourcetype=splunkd log_level!=INFO
| timechart count by component useother=f limit=5&amp;lt;/query&amp;gt;
          &amp;lt;earliest&amp;gt;-60m@m&amp;lt;/earliest&amp;gt;
          &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
          &amp;lt;sampleRatio&amp;gt;1&amp;lt;/sampleRatio&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;option name="count"&amp;gt;5&amp;lt;/option&amp;gt;
        &amp;lt;option name="dataOverlayMode"&amp;gt;none&amp;lt;/option&amp;gt;
        &amp;lt;option name="drilldown"&amp;gt;none&amp;lt;/option&amp;gt;
        &amp;lt;option name="percentagesRow"&amp;gt;false&amp;lt;/option&amp;gt;
        &amp;lt;option name="rowNumbers"&amp;gt;true&amp;lt;/option&amp;gt;
        &amp;lt;option name="totalsRow"&amp;gt;false&amp;lt;/option&amp;gt;
        &amp;lt;option name="wrap"&amp;gt;true&amp;lt;/option&amp;gt;
      &amp;lt;/table&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
&amp;lt;/dashboard&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Following is the required JS file &lt;CODE&gt;table_row_number_header_extension.js&lt;/CODE&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; require([
     'underscore',
     'jquery',
     'splunkjs/mvc',
     'splunkjs/mvc/tableview',
     'splunkjs/mvc/simplexml/ready!'
 ], function(_, $, mvc, TableView) {
     mvc.Components.get("tableWithRowNumAndHeader").getVisualization(function(tableView) {
         tableView.on('rendered', function() {
             setTimeout(function(){
                 $("div#tableWithRowNumAndHeader table thead th.row-number").html("Row #");
             },100);
         });
     });
 });
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 13 Nov 2019 15:14:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-a-header-for-row-numbers-in-a-column/m-p/482868#M31654</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2019-11-13T15:14:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a header for row numbers in a column</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-a-header-for-row-numbers-in-a-column/m-p/482869#M31655</link>
      <description>&lt;P&gt;@ niketnilay ,&lt;BR /&gt;
    thanks for your reply, It's work fine, I want to know more about Table Render extension, where can i find more about this knowledge?&lt;/P&gt;</description>
      <pubDate>Thu, 14 Nov 2019 07:36:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-a-header-for-row-numbers-in-a-column/m-p/482869#M31655</guid>
      <dc:creator>zzjcfj</dc:creator>
      <dc:date>2019-11-14T07:36:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a header for row numbers in a column</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-a-header-for-row-numbers-in-a-column/m-p/482870#M31656</link>
      <description>&lt;P&gt;@zzjcfj one of the first place should be to try out the &lt;A href="https://splunkbase.splunk.com/app/1603/"&gt;Splunk Dashboard Examples&lt;/A&gt; app which comes with alot of Table Render Extension examples. The complete documentation on Splunk Web Framework is available on &lt;/P&gt;

&lt;P&gt;Splunk Docs : &lt;A href="https://docs.splunk.com/DocumentationStatic/WebFramework/1.0/"&gt;https://docs.splunk.com/DocumentationStatic/WebFramework/1.0/&lt;/A&gt; &lt;BR /&gt;
Splunk Dev : &lt;A href="https://dev.splunk.com/enterprise/docs/developapps/webframework/displaydataview/howtocreatecustomtablerow/"&gt;https://dev.splunk.com/enterprise/docs/developapps/webframework/displaydataview/howtocreatecustomtablerow/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Feb 2020 03:38:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-a-header-for-row-numbers-in-a-column/m-p/482870#M31656</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2020-02-06T03:38:26Z</dc:date>
    </item>
  </channel>
</rss>

