<?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: Dynamically update table based on number of splunk searches in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Dynamically-update-table-based-on-number-of-splunk-searches/m-p/326874#M97410</link>
    <description>&lt;P&gt;Hi All,&lt;/P&gt;

&lt;P&gt;This issue of updating splunk table dynamically is resolved. Table will not be updated automatically by removing id. To update table contents on every time search is executed, we need to remove already existing table contents and add the contents.&lt;BR /&gt;
Every time below search executes, its search id &lt;CODE&gt;search_id&lt;/CODE&gt; should be linked to table element managerid like below code:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;      search_query = new SearchManager({
            "id": search_id,
            "status_buckets": 0,
            "cancelOnUnload": true,
            "search": search_cmd,
            "latest_time": "$latest$",
            "earliest_time": "$earliest$",
            "app": utils.getCurrentApp(),
            "auto_cancel": 90,
            "preview": true,
            "runWhenTimeIsUndefined": false,
            "timeout": "10"
        }, {tokens: true});

       var element1 = new TableElement({
            "id": search_id_table,
            "drilldown": "row",
            "rowNumbers": "undefined",
            "wrap": "undefined",
            "managerid": search_id,
            "el": $('#element1')
        }, {tokens: true}).render();

       # This removes the Table contents. So we need to add table after its been removed.
       mvc.Components.getInstance(search_id_table).remove();

       # Adding splunk table element with innerHTML
       document.getElementById("row1").innerHTML+= '&amp;lt;div id="panel1" class="dashboard-cell" style="width: 100%;"&amp;gt;  &amp;lt;div class="dashboard-panel clearfix"&amp;gt; &amp;lt;div class="panel-element-row"&amp;gt; &amp;lt;div id="element1" class="dashboard-element table" style="width: 100%"&amp;gt;  &amp;lt;div class="panel-head"&amp;gt; &amp;lt;h3&amp;gt;Query Table&amp;lt;/h3&amp;gt; &amp;lt;/div&amp;gt; &amp;lt;div class="panel-body"&amp;gt;&amp;lt;/div&amp;gt; &amp;lt;/div&amp;gt; &amp;lt;/div&amp;gt; &amp;lt;/div&amp;gt; &amp;lt;/div&amp;gt;';
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This code helps you to update Splunk table dymanically everytime u execute Splunk search with search result.&lt;/P&gt;</description>
    <pubDate>Mon, 24 Jul 2017 11:34:15 GMT</pubDate>
    <dc:creator>sumangala</dc:creator>
    <dc:date>2017-07-24T11:34:15Z</dc:date>
    <item>
      <title>Dynamically update table based on number of splunk searches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Dynamically-update-table-based-on-number-of-splunk-searches/m-p/326870#M97406</link>
      <description>&lt;P&gt;Hi Splunkers,&lt;/P&gt;

&lt;P&gt;I need to update table element based on splunk search result. To achieve this I need to map with splunk search id &lt;CODE&gt;search_id&lt;/CODE&gt; to manager id of the table to display search result into table. Splunk search changes every time, but same table needs to be updated with latest result. Problem here is I need to provide every time new id (currently &lt;CODE&gt;search_id_table&lt;/CODE&gt;) to table element which generates new table instead of updating table. With same table id, it gives error &lt;CODE&gt;Uncaught Error: Already have instance with id: in Splunk&lt;/CODE&gt;&lt;BR /&gt;
Do u have any idea regarding this?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  search_query = new SearchManager({
         "id": search_id,
         "status_buckets": 0,
         "cancelOnUnload": true,
         "search": search_cmd,
         "latest_time": "$latest$",
         "earliest_time": "$earliest$",
         "app": utils.getCurrentApp(),
         "auto_cancel": 90,
         "preview": true,
         "runWhenTimeIsUndefined": false,
         "timeout": "10"
     }, {tokens: true});

     var element1 = new TableElement({
         "id": search_id_table,
         "drilldown": "row",
         "rowNumbers": "undefined",
         "wrap": "undefined",
         "managerid": search_id,
         "el": $('#element1')
     }, {tokens: true}).render();
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 20 Jul 2017 12:53:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Dynamically-update-table-based-on-number-of-splunk-searches/m-p/326870#M97406</guid>
      <dc:creator>sumangala</dc:creator>
      <dc:date>2017-07-20T12:53:41Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically update table based on number of splunk searches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Dynamically-update-table-based-on-number-of-splunk-searches/m-p/326871#M97407</link>
      <description>&lt;P&gt;Hi Sumangala,&lt;/P&gt;

&lt;P&gt;Don't use id on element1. splunk automatically assign id to table element.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  var element1 = new TableElement({      
      "drilldown": "row",
      "rowNumbers": "undefined",
      "wrap": "undefined",
      "managerid": search_id,
      "el": $('#element1')
  }, {tokens: true}).render();
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;i hope it helps&lt;/P&gt;

&lt;P&gt;Regards,&lt;BR /&gt;
Badri &lt;/P&gt;</description>
      <pubDate>Thu, 20 Jul 2017 14:05:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Dynamically-update-table-based-on-number-of-splunk-searches/m-p/326871#M97407</guid>
      <dc:creator>sbbadri</dc:creator>
      <dc:date>2017-07-20T14:05:50Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically update table based on number of splunk searches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Dynamically-update-table-based-on-number-of-splunk-searches/m-p/326872#M97408</link>
      <description>&lt;P&gt;Hi sbbadri,&lt;/P&gt;

&lt;P&gt;I have tried this initially, after removing ID for &lt;CODE&gt;TableElement&lt;/CODE&gt; splunk automatically assigns the new ID. But, this creates new instance of the table and new table will be generated instead of updating already existing of table contents(as per below image).&lt;BR /&gt;
Is there any other way to update table contents?&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/3248i2530A953BF13ACC0/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>Fri, 21 Jul 2017 05:34:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Dynamically-update-table-based-on-number-of-splunk-searches/m-p/326872#M97408</guid>
      <dc:creator>sumangala</dc:creator>
      <dc:date>2017-07-21T05:34:24Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically update table based on number of splunk searches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Dynamically-update-table-based-on-number-of-splunk-searches/m-p/326873#M97409</link>
      <description>&lt;P&gt;@sumangala, If you want to change a setting for Table Element &lt;STRONG&gt;element1&lt;/STRONG&gt; , instead of creating the same element, you can access it via &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;var myTableElement= mvc.Components.get('element1');
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then, you can apply the changes or extension as per your need. Refer to several examples in Splunk 6.x Dashboard Examples app regarding the same like Table Row Highlighting.&lt;BR /&gt;
You should also check out Splunk Web Framework details on Splunk Documentation (&lt;A href="http://docs.splunk.com/Documentation/WebFramework"&gt;http://docs.splunk.com/Documentation/WebFramework&lt;/A&gt;) and Splunk Dev site (&lt;A href="http://dev.splunk.com/view/SP-CAAAE49"&gt;http://dev.splunk.com/view/SP-CAAAE49&lt;/A&gt;) to understand it better. &lt;/P&gt;</description>
      <pubDate>Fri, 21 Jul 2017 06:20:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Dynamically-update-table-based-on-number-of-splunk-searches/m-p/326873#M97409</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-07-21T06:20:30Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically update table based on number of splunk searches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Dynamically-update-table-based-on-number-of-splunk-searches/m-p/326874#M97410</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;

&lt;P&gt;This issue of updating splunk table dynamically is resolved. Table will not be updated automatically by removing id. To update table contents on every time search is executed, we need to remove already existing table contents and add the contents.&lt;BR /&gt;
Every time below search executes, its search id &lt;CODE&gt;search_id&lt;/CODE&gt; should be linked to table element managerid like below code:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;      search_query = new SearchManager({
            "id": search_id,
            "status_buckets": 0,
            "cancelOnUnload": true,
            "search": search_cmd,
            "latest_time": "$latest$",
            "earliest_time": "$earliest$",
            "app": utils.getCurrentApp(),
            "auto_cancel": 90,
            "preview": true,
            "runWhenTimeIsUndefined": false,
            "timeout": "10"
        }, {tokens: true});

       var element1 = new TableElement({
            "id": search_id_table,
            "drilldown": "row",
            "rowNumbers": "undefined",
            "wrap": "undefined",
            "managerid": search_id,
            "el": $('#element1')
        }, {tokens: true}).render();

       # This removes the Table contents. So we need to add table after its been removed.
       mvc.Components.getInstance(search_id_table).remove();

       # Adding splunk table element with innerHTML
       document.getElementById("row1").innerHTML+= '&amp;lt;div id="panel1" class="dashboard-cell" style="width: 100%;"&amp;gt;  &amp;lt;div class="dashboard-panel clearfix"&amp;gt; &amp;lt;div class="panel-element-row"&amp;gt; &amp;lt;div id="element1" class="dashboard-element table" style="width: 100%"&amp;gt;  &amp;lt;div class="panel-head"&amp;gt; &amp;lt;h3&amp;gt;Query Table&amp;lt;/h3&amp;gt; &amp;lt;/div&amp;gt; &amp;lt;div class="panel-body"&amp;gt;&amp;lt;/div&amp;gt; &amp;lt;/div&amp;gt; &amp;lt;/div&amp;gt; &amp;lt;/div&amp;gt; &amp;lt;/div&amp;gt;';
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This code helps you to update Splunk table dymanically everytime u execute Splunk search with search result.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jul 2017 11:34:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Dynamically-update-table-based-on-number-of-splunk-searches/m-p/326874#M97410</guid>
      <dc:creator>sumangala</dc:creator>
      <dc:date>2017-07-24T11:34:15Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically update table based on number of splunk searches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Dynamically-update-table-based-on-number-of-splunk-searches/m-p/326875#M97411</link>
      <description>&lt;P&gt;@niketnilay:&lt;BR /&gt;
Thank you for providing good documentation links.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jul 2017 11:36:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Dynamically-update-table-based-on-number-of-splunk-searches/m-p/326875#M97411</guid>
      <dc:creator>sumangala</dc:creator>
      <dc:date>2017-07-24T11:36:12Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically update table based on number of splunk searches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Dynamically-update-table-based-on-number-of-splunk-searches/m-p/326876#M97412</link>
      <description>&lt;P&gt;Hi badri,&lt;/P&gt;

&lt;P&gt;After removing table id, splunk automatically assigns new id to the table. But, it used to create new instance everytime with new table as shown in above commented image.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jul 2017 11:38:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Dynamically-update-table-based-on-number-of-splunk-searches/m-p/326876#M97412</guid>
      <dc:creator>sumangala</dc:creator>
      <dc:date>2017-07-24T11:38:45Z</dc:date>
    </item>
  </channel>
</rss>

