<?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 Token value change does not update Search Manager in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/Token-value-change-does-not-update-Search-Manager/m-p/242819#M15077</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;Generally I want to have an text input field where you can enter an String which updates the table view.&lt;BR /&gt;
Now when I am opening the Site he uses the default value of the text input field, but when I am changing the text in the txt input field the table view will not get updated. Do you have any hints what the problem is?&lt;/P&gt;

&lt;P&gt;Regards Johann&lt;/P&gt;

&lt;P&gt;JavaScript:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;require([
    'jquery',
    'underscore',
    'splunkjs/ready!',
    'splunkjs/mvc/searchmanager',
    'splunkjs/mvc/tableview',
    'splunkjs/mvc/textinputview',
    ],
    function(
       $,
        _,
        mvc,
        SearchManager,
        TableView,
        TextInputView
    ) {

        var tokens = mvc.Components.getInstance("default");

        var tableView1 = new TableView({
            id: 'table1',
            managerid: 'simplesearch1',
            el: $('#table1')
        }).render();

        var table2 = new TableView({
            id: 'table2',
            managerid: 'simplesearch1',
            el: $('#table2')
        }).render();

           var textinput1 = new TextInputView({
                 id: "tf",
                default: "*",
                  value: mvc.tokenSafe("$searchQuery$"),
                  el: $("#tf")
            }).render();

        var ICONS = {
            severe: 'alert-circle',
            elevated: 'alert',
            low: 'check-circle'
        };

        var CustomIconCellRenderer = TableView.BaseCellRenderer.extend({
            canRender: function(cell) {
                return cell.field === 'range';
            },

            render: function($td, cell) {
                var icon = 'question';
                if(ICONS.hasOwnProperty(cell.value)) {
                    icon = ICONS[cell.value];
                }
                $td.addClass('icon').html(_.template('&amp;lt;i class="icon-&amp;lt;%-icon%&amp;gt; &amp;lt;%- range %&amp;gt;" title="&amp;lt;%- range %&amp;gt;"&amp;gt;&amp;lt;/i&amp;gt;', {
                    icon: icon,
                    range: cell.value
                }));
            }
        });



        new SearchManager({
            id: 'simplesearch1',
            search: mvc.tokenSafe("index=_internal | search $searchQuery$ | head 10000 | stats count by sourcetype,source,host | rangemap field=count low=0-100 elevated=101-1000 default=severe"),
            //cache: true,
            preview: true,
            //autostart: true
        });

        tableView1.table.addCellRenderer(new CustomIconCellRenderer());
        tableView1.table.render();
    }
);
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;XML:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;dashboard script="ip_profiler.js" stylesheet="ip_profiler.css"&amp;gt;

  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
        &amp;lt;html&amp;gt;
          &amp;lt;div id="tf"&amp;gt;&amp;lt;/div&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="table1"&amp;gt;
        &amp;lt;option name="wrap"&amp;gt;undefined&amp;lt;/option&amp;gt;
        &amp;lt;option name="rowNumbers"&amp;gt;undefined&amp;lt;/option&amp;gt;
        &amp;lt;option name="drilldown"&amp;gt;row&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;</description>
    <pubDate>Mon, 25 Jan 2016 11:44:22 GMT</pubDate>
    <dc:creator>johannschmid</dc:creator>
    <dc:date>2016-01-25T11:44:22Z</dc:date>
    <item>
      <title>Token value change does not update Search Manager</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Token-value-change-does-not-update-Search-Manager/m-p/242819#M15077</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;Generally I want to have an text input field where you can enter an String which updates the table view.&lt;BR /&gt;
Now when I am opening the Site he uses the default value of the text input field, but when I am changing the text in the txt input field the table view will not get updated. Do you have any hints what the problem is?&lt;/P&gt;

&lt;P&gt;Regards Johann&lt;/P&gt;

&lt;P&gt;JavaScript:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;require([
    'jquery',
    'underscore',
    'splunkjs/ready!',
    'splunkjs/mvc/searchmanager',
    'splunkjs/mvc/tableview',
    'splunkjs/mvc/textinputview',
    ],
    function(
       $,
        _,
        mvc,
        SearchManager,
        TableView,
        TextInputView
    ) {

        var tokens = mvc.Components.getInstance("default");

        var tableView1 = new TableView({
            id: 'table1',
            managerid: 'simplesearch1',
            el: $('#table1')
        }).render();

        var table2 = new TableView({
            id: 'table2',
            managerid: 'simplesearch1',
            el: $('#table2')
        }).render();

           var textinput1 = new TextInputView({
                 id: "tf",
                default: "*",
                  value: mvc.tokenSafe("$searchQuery$"),
                  el: $("#tf")
            }).render();

        var ICONS = {
            severe: 'alert-circle',
            elevated: 'alert',
            low: 'check-circle'
        };

        var CustomIconCellRenderer = TableView.BaseCellRenderer.extend({
            canRender: function(cell) {
                return cell.field === 'range';
            },

            render: function($td, cell) {
                var icon = 'question';
                if(ICONS.hasOwnProperty(cell.value)) {
                    icon = ICONS[cell.value];
                }
                $td.addClass('icon').html(_.template('&amp;lt;i class="icon-&amp;lt;%-icon%&amp;gt; &amp;lt;%- range %&amp;gt;" title="&amp;lt;%- range %&amp;gt;"&amp;gt;&amp;lt;/i&amp;gt;', {
                    icon: icon,
                    range: cell.value
                }));
            }
        });



        new SearchManager({
            id: 'simplesearch1',
            search: mvc.tokenSafe("index=_internal | search $searchQuery$ | head 10000 | stats count by sourcetype,source,host | rangemap field=count low=0-100 elevated=101-1000 default=severe"),
            //cache: true,
            preview: true,
            //autostart: true
        });

        tableView1.table.addCellRenderer(new CustomIconCellRenderer());
        tableView1.table.render();
    }
);
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;XML:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;dashboard script="ip_profiler.js" stylesheet="ip_profiler.css"&amp;gt;

  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
        &amp;lt;html&amp;gt;
          &amp;lt;div id="tf"&amp;gt;&amp;lt;/div&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="table1"&amp;gt;
        &amp;lt;option name="wrap"&amp;gt;undefined&amp;lt;/option&amp;gt;
        &amp;lt;option name="rowNumbers"&amp;gt;undefined&amp;lt;/option&amp;gt;
        &amp;lt;option name="drilldown"&amp;gt;row&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;</description>
      <pubDate>Mon, 25 Jan 2016 11:44:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Token-value-change-does-not-update-Search-Manager/m-p/242819#M15077</guid>
      <dc:creator>johannschmid</dc:creator>
      <dc:date>2016-01-25T11:44:22Z</dc:date>
    </item>
    <item>
      <title>Re: Token value change does not update Search Manager</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Token-value-change-does-not-update-Search-Manager/m-p/242820#M15078</link>
      <description>&lt;P&gt;It looks like you are missing the code to react to the text input value change, like so:&lt;BR /&gt;
 &lt;CODE&gt;textinput1.on("change", function(newValue) {&lt;BR /&gt;
            FormUtils.handleValueChange(textinput1);&lt;BR /&gt;
        });&lt;/CODE&gt;&lt;BR /&gt;
I would try adding that and see if it executes your search again.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jan 2016 23:16:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Token-value-change-does-not-update-Search-Manager/m-p/242820#M15078</guid>
      <dc:creator>s2_splunk</dc:creator>
      <dc:date>2016-01-26T23:16:42Z</dc:date>
    </item>
  </channel>
</rss>

