<?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 do you add buttons on table view? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-add-buttons-on-table-view/m-p/384713#M112365</link>
    <description>&lt;P&gt;without using Sideview util, only js and css please&lt;/P&gt;

&lt;P&gt;regards&lt;/P&gt;</description>
    <pubDate>Tue, 18 Sep 2018 15:51:21 GMT</pubDate>
    <dc:creator>antoniofacchi</dc:creator>
    <dc:date>2018-09-18T15:51:21Z</dc:date>
    <item>
      <title>How do you add buttons on table view?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-add-buttons-on-table-view/m-p/384712#M112364</link>
      <description>&lt;P&gt;Goodmorning,&lt;/P&gt;

&lt;P&gt;I have a Simple-XML with following search&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal source=*metrics.log group="per_sourcetype_thruput"
 | head 1000 
| stats sum(kb) as totalKB by series 
| eval actions="PLACEHOLDER" 
| streamstats count 
| eval showme=if(count=="2","true","false")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I would like to add a button in each row based on "showme". If "showme=true" links a url " and if "showme=false" links a different url.&lt;/P&gt;

&lt;P&gt;How can I do it please?&lt;BR /&gt;
many thanks and regards&lt;BR /&gt;
Antonio&lt;/P&gt;</description>
      <pubDate>Tue, 18 Sep 2018 13:47:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-add-buttons-on-table-view/m-p/384712#M112364</guid>
      <dc:creator>antoniofacchi</dc:creator>
      <dc:date>2018-09-18T13:47:57Z</dc:date>
    </item>
    <item>
      <title>Re: How do you add buttons on table view?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-add-buttons-on-table-view/m-p/384713#M112365</link>
      <description>&lt;P&gt;without using Sideview util, only js and css please&lt;/P&gt;

&lt;P&gt;regards&lt;/P&gt;</description>
      <pubDate>Tue, 18 Sep 2018 15:51:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-add-buttons-on-table-view/m-p/384713#M112365</guid>
      <dc:creator>antoniofacchi</dc:creator>
      <dc:date>2018-09-18T15:51:21Z</dc:date>
    </item>
    <item>
      <title>Re: How do you add buttons on table view?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-add-buttons-on-table-view/m-p/384714#M112366</link>
      <description>&lt;P&gt;@antoniofacchi the behavior of Drilldown depending on Specific column value i.e. true/false in your case that you want can be built using built in Splunk Drilldown behavior. You should Check out &lt;A href="https://splunkbase.splunk.com/app/1603/"&gt;Splunk Dashboard Examples&lt;/A&gt; app for examples to drilldown to URL (using hidden URL filed in the table).&lt;/P&gt;

&lt;P&gt;If you need to show the link as Buttons (or clickable Links), following are couple of your options:&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/5811i51E71B0AE41A0589/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;1) Create URL field within your SPL. I have extended your run anywhere example based on Splunk's _internal index to set every &lt;CODE&gt;odd row for Google&lt;/CODE&gt; and &lt;CODE&gt;even row for Splunk Answers&lt;/CODE&gt; using &lt;CODE&gt;modular division by 2&lt;/CODE&gt;.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal source=*metrics.log group="per_sourcetype_thruput"
| stats sum(kb) as totalKB by series
| head 10
| eval actions="PLACEHOLDER" 
| streamstats count 
| eval "Click Me"=if(count%2=0,"Google","Answers")
| eval URL=if(count%2=0,"https://www.google.com/search?q=","https://answers.splunk.com/search.html?f=&amp;amp;redirect=search%2Fsearch&amp;amp;sort=relevance&amp;amp;type=question&amp;amp;q=")
| table series totalKB actions "Click Me" URL
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;2) Hide the URL field using the &lt;CODE&gt;&amp;lt;fields&amp;gt;&lt;/CODE&gt; table Simple XML configuration. Show all fields except URL i.e.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    &amp;lt;fields&amp;gt;["series","totalKB","actions","Click Me"]&amp;lt;/fields&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;3) Create Drilldown link using row tokens which gets the URL from hidden URL field and any other option parameter using $row.yourFieldName$ as querystring. Following is the example used:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    &amp;lt;drilldown&amp;gt;
      &amp;lt;condition field="Click Me"&amp;gt;
        &amp;lt;eval token="tokCombined"&amp;gt;$row.URL|n$$row.series|n$&amp;lt;/eval&amp;gt;
        &amp;lt;link target="_blank"&amp;gt;
          &amp;lt;![CDATA[$row.URL|n$$row.series|n$]]&amp;gt;
        &amp;lt;/link&amp;gt;
      &amp;lt;/condition&amp;gt;
      &amp;lt;condition&amp;gt;
        &amp;lt;!-- No Drilldown on Other Columns --&amp;gt;
      &amp;lt;/condition&amp;gt;
    &amp;lt;/drilldown&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;PS: &lt;CODE&gt;&amp;lt;condition&amp;gt;&lt;/CODE&gt; block takes care of enabling the drilldown only for &lt;CODE&gt;Click Me&lt;/CODE&gt; column and not for any other column.&lt;BR /&gt;
4) Set the CSS for disabling drilldown cursor and link color for all fields (if required can be set for specific column depending on option adopted)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;        cursor: default !important;
        color: black !important;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;Option 1: Use Unicode Icon for URL Drilldown&lt;/STRONG&gt;&lt;BR /&gt;
Uses Unicode Characters within table. Hence no JS Extension needs to be applied. Refer to one previous Example on Similar line: &lt;A href="https://answers.splunk.com/answers/681268/one-rangemap-column-for-multiple-values.html"&gt;https://answers.splunk.com/answers/681268/one-rangemap-column-for-multiple-values.html&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;If you are on Splunk Enterprise 6.5 or higher, color for Table Cells can be applied using UI Edit Format option for specific column (in this case &lt;CODE&gt;Click Me&lt;/CODE&gt;).&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Option 2: Use HTML Button for URL Drilldown&lt;/STRONG&gt;&lt;BR /&gt;
You can use Simple XML JS extension to apply a custom table cell renderer for Specific Column in a table to add html button &lt;CODE&gt;&amp;lt;input&amp;gt;&lt;/CODE&gt; to each row.&lt;BR /&gt;
&lt;CODE&gt;btn-primary&lt;/CODE&gt; bootstrap class can be added for Splunk specific Submit button formatting. Additional formatting like Button Size and Position can be set using custom class for CSS Selector.&lt;/P&gt;

&lt;P&gt;Refer to one of my older andwers on Similar lines which adds a Text Box to each row in the table instead of a Button. &lt;A href="https://answers.splunk.com/answers/682183/how-to-add-a-textbox-as-a-cell-in-a-splunk-table.html"&gt;https://answers.splunk.com/answers/682183/how-to-add-a-textbox-as-a-cell-in-a-splunk-table.html&lt;/A&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;      #tableWithButton table tbody tr td input.table-button{
        width: 83px !important;
        position: relative;
        left: 30%;
      }
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Following is the complete &lt;CODE&gt;Simple XML Code&lt;/CODE&gt; for attached run anywhere example screenshot &lt;BR /&gt;
(PS: Since Option 1 Uses Unicode which Splunk Answers does not post correctly, I will attach screenshot for Option 1 with &lt;A href="https://www.compart.com/en/unicode/U+1F5B0"&gt;Unicode Character for Two Button Mouse&lt;/A&gt;.):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;dashboard script="table_with_buttons.js"&amp;gt;
  &amp;lt;label&amp;gt;Link to URL based on Value&amp;lt;/label&amp;gt;
  &amp;lt;row depends="$alwaysHideCSSPanel$"&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;html&amp;gt;
        &amp;lt;style&amp;gt;
          #tableWithIcon table tbody tr td{
            cursor: default !important;
            color: black !important;
          }
          &amp;lt;!-- 4th Child is the column with Drilldown Link --&amp;gt;
          #tableWithIcon table tbody tr td:nth-child(4){
            cursor: pointer !important;
            color: blue !important;
          }
          #tableWithButton table tbody tr td{
            cursor: default !important;
            color: black !important;
          }
          #tableWithButton table tbody tr td input.table-button{
            width: 83px !important;
            position: relative;
            left: 30%;
          }
        &amp;lt;/style&amp;gt;
      &amp;lt;/html&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;table id="tableWithIcon"&amp;gt;
        &amp;lt;title&amp;gt;Option 1: Use Unicode Icon for URL drilldown (hidden URL field)&amp;lt;/title&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;index=_internal source=*metrics.log group="per_sourcetype_thruput"
| stats sum(kb) as totalKB by series
| head 10
| eval actions="PLACEHOLDER" 
| streamstats count 
| eval "Click Me"=if(count%2=0,"Google","Answers")
| eval URL=if(count%2=0,"https://www.google.com/search?q=","https://answers.splunk.com/search.html?f=&amp;amp;amp;redirect=search%2Fsearch&amp;amp;amp;sort=relevance&amp;amp;amp;type=question&amp;amp;amp;q=")
| table series totalKB actions "Click Me" URL&amp;lt;/query&amp;gt;
          &amp;lt;earliest&amp;gt;-24h@h&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;10&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;cell&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;false&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;format type="color" field="Click Me"&amp;gt;
          &amp;lt;colorPalette type="map"&amp;gt;{"Google":#A1FE65,"Answers":#72E5E1}&amp;lt;/colorPalette&amp;gt;
        &amp;lt;/format&amp;gt;
        &amp;lt;fields&amp;gt;["series","totalKB","actions","Click Me"]&amp;lt;/fields&amp;gt;
        &amp;lt;drilldown&amp;gt;
          &amp;lt;condition field="Click Me"&amp;gt;
            &amp;lt;eval token="tokCombined"&amp;gt;$row.URL|n$$row.series|n$&amp;lt;/eval&amp;gt;
            &amp;lt;link target="_blank"&amp;gt;
              &amp;lt;![CDATA[$row.URL|n$$row.series|n$]]&amp;gt;
            &amp;lt;/link&amp;gt;
          &amp;lt;/condition&amp;gt;
          &amp;lt;condition&amp;gt;
            &amp;lt;!-- No Drilldown on Other Columns --&amp;gt;
          &amp;lt;/condition&amp;gt;
        &amp;lt;/drilldown&amp;gt;
      &amp;lt;/table&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;table id="tableWithButton"&amp;gt;
        &amp;lt;title&amp;gt;Option 2: Use HTML Button for URL drilldown (hidden URL field)&amp;lt;/title&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;index=_internal source=*metrics.log group="per_sourcetype_thruput"
| stats sum(kb) as totalKB by series
| head 10
| eval actions="PLACEHOLDER" 
| streamstats count 
| eval "Click Me"=if(count%2=0,"Google","Answers")
| eval URL=if(count%2=0,"https://www.google.com/search?q=","https://answers.splunk.com/search.html?f=&amp;amp;amp;redirect=search%2Fsearch&amp;amp;amp;sort=relevance&amp;amp;amp;type=question&amp;amp;amp;q=")
| table series totalKB actions "Click Me" URL&amp;lt;/query&amp;gt;
          &amp;lt;earliest&amp;gt;-24h@h&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;10&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;cell&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;false&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;fields&amp;gt;["series","totalKB","actions","Click Me"]&amp;lt;/fields&amp;gt;
        &amp;lt;drilldown&amp;gt;
          &amp;lt;condition field="Click Me"&amp;gt;
            &amp;lt;eval token="tokCombined"&amp;gt;$row.URL|n$$row.series|n$&amp;lt;/eval&amp;gt;
            &amp;lt;link target="_blank"&amp;gt;
              &amp;lt;![CDATA[$row.URL|n$$row.series|n$]]&amp;gt;
            &amp;lt;/link&amp;gt;
          &amp;lt;/condition&amp;gt;
          &amp;lt;condition&amp;gt;
            &amp;lt;!-- No Drilldown on Other Columns --&amp;gt;
          &amp;lt;/condition&amp;gt;
        &amp;lt;/drilldown&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 JavaScript file &lt;CODE&gt;table_with_buttons.js&lt;/CODE&gt; for Option 2 with Submit buttons to Display and work.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; require([
      'underscore',
      'jquery',
      'splunkjs/mvc',
      'splunkjs/mvc/tableview',
      'splunkjs/mvc/simplexml/ready!'
  ], function(_, $, mvc, TableView) {

      var CustomRangeRenderer = TableView.BaseCellRenderer.extend({
          canRender: function(cell) {
              // Enable this custom cell renderer for Person field
              return _(["Click Me"]).contains(cell.field);
          },
          render: function($td, cell) {
              // Add a class to the cell based on the returned value
              var strCellValue = cell.value;

              if (cell.field === "Click Me") {
                  var strHtmlInput="&amp;lt;input type='button' class='table-button btn-primary' value='"+strCellValue+"'&amp;gt;&amp;lt;/input&amp;gt;";
                  //Add TextBox With Specific Style
                 $td.append(strHtmlInput);
              }
          }
      });

      mvc.Components.get('tableWithButton').getVisualization(function(tableView) {
          // Add custom cell renderer, the table will re-render automatically.
          tableView.addCellRenderer(new CustomRangeRenderer());
      });
  });
&lt;/CODE&gt;&lt;/PRE&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/5812iA08DD69D95FA2E47/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>Tue, 18 Sep 2018 20:01:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-add-buttons-on-table-view/m-p/384714#M112366</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-09-18T20:01:02Z</dc:date>
    </item>
    <item>
      <title>Re: How do you add buttons on table view?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-add-buttons-on-table-view/m-p/384715#M112367</link>
      <description>&lt;P&gt;Thank you Niketnilay, I appreciate  your option 2.&lt;BR /&gt;
And in this case could be possible to execute two different CLI commands  when I press the buttons?&lt;BR /&gt;
 The CLI commands are in /bin path.&lt;/P&gt;

&lt;P&gt;Thank you very much.&lt;BR /&gt;
regards&lt;BR /&gt;
Antonio&lt;/P&gt;</description>
      <pubDate>Tue, 25 Sep 2018 14:09:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-add-buttons-on-table-view/m-p/384715#M112367</guid>
      <dc:creator>antoniofacchi</dc:creator>
      <dc:date>2018-09-25T14:09:34Z</dc:date>
    </item>
    <item>
      <title>Re: How do you add buttons on table view?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-add-buttons-on-table-view/m-p/384716#M112368</link>
      <description>&lt;P&gt;@antoniofacchi you can invoke &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Script"&gt;script&lt;/A&gt; command based on button clicked. Please try out and confirm. Let us know if you need further assistance. If your issue is resolved, do accept/up vote the answer!&lt;/P&gt;</description>
      <pubDate>Mon, 29 Oct 2018 17:53:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-add-buttons-on-table-view/m-p/384716#M112368</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-10-29T17:53:24Z</dc:date>
    </item>
  </channel>
</rss>

