<?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 How can I integrate the time constraint from my time input token in JavaScript for a table with expandable rows? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-integrate-the-time-constraint-from-my-time-input-token/m-p/219140#M64409</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I have created a table with expandable rows:&lt;/P&gt;

&lt;P&gt;Code for the table:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;form script="expand_alerts.js"&amp;gt;
  &amp;lt;label&amp;gt;SIEM&amp;lt;/label&amp;gt;
  &amp;lt;fieldset submitButton="false" autoRun="false"&amp;gt;
    &amp;lt;input type="time" token="TimeRangePicker" searchWhenChanged="true"&amp;gt;
      &amp;lt;label&amp;gt;TimeRange&amp;lt;/label&amp;gt;
      &amp;lt;default&amp;gt;
        &amp;lt;earliest&amp;gt;@d&amp;lt;/earliest&amp;gt;
        &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
      &amp;lt;/default&amp;gt;
    &amp;lt;/input&amp;gt;
  &amp;lt;/fieldset&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;table id="expand_with_events"&amp;gt;
        &amp;lt;title&amp;gt;Alerts&amp;lt;/title&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;source="*suricata*" | stats distinct_count(src_ip) AS src_ip distinct_count(dest_ip) AS dest_ip sparkline count by alert.signature_id alert.signature alert.category | sort -count | table alert.signature_id alert.signature alert.category count src_ip dest_ip sparkline&amp;lt;/query&amp;gt;
          &amp;lt;earliest&amp;gt;$TimeRangePicker.earliest$&amp;lt;/earliest&amp;gt;
          &amp;lt;latest&amp;gt;$TimeRangePicker.latest$&amp;lt;/latest&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;option name="wrap"&amp;gt;true&amp;lt;/option&amp;gt;
        &amp;lt;option name="rowNumbers"&amp;gt;false&amp;lt;/option&amp;gt;
        &amp;lt;option name="drilldown"&amp;gt;cell&amp;lt;/option&amp;gt;
        &amp;lt;option name="dataOverlayMode"&amp;gt;none&amp;lt;/option&amp;gt;
        &amp;lt;option name="count"&amp;gt;10&amp;lt;/option&amp;gt;
      &amp;lt;/table&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
&amp;lt;/form&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;When expanded, it shows related events using &lt;CODE&gt;EventsViewer&lt;/CODE&gt;, as follows:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;require([
    'splunkjs/mvc/tableview',
    'splunkjs/mvc/eventsviewerview',
    'splunkjs/mvc/searchmanager',
    'splunkjs/mvc',
    'underscore',
    'splunkjs/mvc/simplexml/ready!'],function(
    TableView,
    EventsViewer,
    SearchManager,
    mvc,
    _
    ){
    var EventSearchBasedRowExpansionRenderer = TableView.BaseRowExpansionRenderer.extend({
        initialize: function(args) {
            // initialize will run once, so we will set up a search and a chart to be reused.
            this._searchManager = new SearchManager({
                id: 'details-search-manager',
                preview: false
            });
            this._eventsViewer = new EventsViewer({
                managerid: 'details-search-manager'
            });
        },
        canRender: function(rowData) {
            // Since more than one row expansion renderer can be registered we let each decide if they can handle that
            // data
            // Here we will always handle it.
            return true;
        },
        render: function($container, rowData) {
            // rowData contains information about the row that is expanded.  We can see the cells, fields, and values
            // We will find the sourcetype cell to use its value
            var alertSignatureIdCell = _(rowData.cells).find(function (cell) {
               return cell.field === 'alert.signature_id';
            });
            //update the search with the sourcetype that we are interested in
            this._searchManager.set({ search: 'source="*suricata*" event_type="alert" alert.signature_id=' + alertSignatureIdCell.value });
            // $container is the jquery object where we can put out content.
            // In this case we will render our chart and add it to the $container
            $container.append(this._eventsViewer.render().el);
        }
    });
    var tableElement = mvc.Components.getInstance("expand_with_events");
    tableElement.getVisualization(function(tableView) {
        // Add custom cell renderer, the table will re-render automatically.
        tableView.addRowExpansionRenderer(new EventSearchBasedRowExpansionRenderer());
    });
});
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;As you can see, the table depends on a time input  (token &lt;CODE&gt;TimeRangePicker&lt;/CODE&gt;) that I am also trying to integrate in the javascript. I have already tried to write something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;require([
    'splunkjs/mvc/tableview',
    'splunkjs/mvc/eventsviewerview',
    'splunkjs/mvc/searchmanager',
    'splunkjs/mvc',
    'underscore',
    'splunkjs/mvc/simplexml/ready!'],function(
    TableView,
    EventsViewer,
    SearchManager,
    mvc,
    _
    ){
    var EventSearchBasedRowExpansionRenderer = TableView.BaseRowExpansionRenderer.extend({
        initialize: function(args) {
            // initialize will run once, so we will set up a search and a chart to be reused.
            this._searchManager = new SearchManager({
                id: 'details-search-manager',
                preview: false
            });
            this._eventsViewer = new EventsViewer({
                managerid: 'details-search-manager'
            });
        },
        canRender: function(rowData) {
            // Since more than one row expansion renderer can be registered we let each decide if they can handle that
            // data
            // Here we will always handle it.
            return true;
        },
        render: function($container, rowData) {
            // rowData contains information about the row that is expanded.  We can see the cells, fields, and values
            // We will find the sourcetype cell to use its value
            var alertSignatureIdCell = _(rowData.cells).find(function (cell) {
               return cell.field === 'alert.signature_id';
            });
            //update the search with the sourcetype that we are interested in
            this._searchManager.set({
                search: 'source="*suricata*" event_type="alert" alert.signature_id=' + alertSignatureIdCell.value,
                earliest_time: $TimeRangePicker.earliest$,
                latest_time: $TimeRangePicker.latest$
            });
            // $container is the jquery object where we can put out content.
            // In this case we will render our chart and add it to the $container
            $container.append(this._eventsViewer.render().el);
        }
    });
    var tableElement = mvc.Components.getInstance("expand_with_events");
    tableElement.getVisualization(function(tableView) {
        // Add custom cell renderer, the table will re-render automatically.
        tableView.addRowExpansionRenderer(new EventSearchBasedRowExpansionRenderer());
    });
});
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But now, rows don't expand and the web console says &lt;CODE&gt;$TimeRangePicker&lt;/CODE&gt; is not defined.&lt;/P&gt;

&lt;P&gt;How can I integrate the time constraint from my time input in the javascript?&lt;/P&gt;

&lt;P&gt;Thank you in advance for your help.&lt;/P&gt;</description>
    <pubDate>Thu, 21 Apr 2016 07:15:30 GMT</pubDate>
    <dc:creator>sebdamaye</dc:creator>
    <dc:date>2016-04-21T07:15:30Z</dc:date>
    <item>
      <title>How can I integrate the time constraint from my time input token in JavaScript for a table with expandable rows?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-integrate-the-time-constraint-from-my-time-input-token/m-p/219140#M64409</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I have created a table with expandable rows:&lt;/P&gt;

&lt;P&gt;Code for the table:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;form script="expand_alerts.js"&amp;gt;
  &amp;lt;label&amp;gt;SIEM&amp;lt;/label&amp;gt;
  &amp;lt;fieldset submitButton="false" autoRun="false"&amp;gt;
    &amp;lt;input type="time" token="TimeRangePicker" searchWhenChanged="true"&amp;gt;
      &amp;lt;label&amp;gt;TimeRange&amp;lt;/label&amp;gt;
      &amp;lt;default&amp;gt;
        &amp;lt;earliest&amp;gt;@d&amp;lt;/earliest&amp;gt;
        &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
      &amp;lt;/default&amp;gt;
    &amp;lt;/input&amp;gt;
  &amp;lt;/fieldset&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;table id="expand_with_events"&amp;gt;
        &amp;lt;title&amp;gt;Alerts&amp;lt;/title&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;source="*suricata*" | stats distinct_count(src_ip) AS src_ip distinct_count(dest_ip) AS dest_ip sparkline count by alert.signature_id alert.signature alert.category | sort -count | table alert.signature_id alert.signature alert.category count src_ip dest_ip sparkline&amp;lt;/query&amp;gt;
          &amp;lt;earliest&amp;gt;$TimeRangePicker.earliest$&amp;lt;/earliest&amp;gt;
          &amp;lt;latest&amp;gt;$TimeRangePicker.latest$&amp;lt;/latest&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;option name="wrap"&amp;gt;true&amp;lt;/option&amp;gt;
        &amp;lt;option name="rowNumbers"&amp;gt;false&amp;lt;/option&amp;gt;
        &amp;lt;option name="drilldown"&amp;gt;cell&amp;lt;/option&amp;gt;
        &amp;lt;option name="dataOverlayMode"&amp;gt;none&amp;lt;/option&amp;gt;
        &amp;lt;option name="count"&amp;gt;10&amp;lt;/option&amp;gt;
      &amp;lt;/table&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
&amp;lt;/form&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;When expanded, it shows related events using &lt;CODE&gt;EventsViewer&lt;/CODE&gt;, as follows:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;require([
    'splunkjs/mvc/tableview',
    'splunkjs/mvc/eventsviewerview',
    'splunkjs/mvc/searchmanager',
    'splunkjs/mvc',
    'underscore',
    'splunkjs/mvc/simplexml/ready!'],function(
    TableView,
    EventsViewer,
    SearchManager,
    mvc,
    _
    ){
    var EventSearchBasedRowExpansionRenderer = TableView.BaseRowExpansionRenderer.extend({
        initialize: function(args) {
            // initialize will run once, so we will set up a search and a chart to be reused.
            this._searchManager = new SearchManager({
                id: 'details-search-manager',
                preview: false
            });
            this._eventsViewer = new EventsViewer({
                managerid: 'details-search-manager'
            });
        },
        canRender: function(rowData) {
            // Since more than one row expansion renderer can be registered we let each decide if they can handle that
            // data
            // Here we will always handle it.
            return true;
        },
        render: function($container, rowData) {
            // rowData contains information about the row that is expanded.  We can see the cells, fields, and values
            // We will find the sourcetype cell to use its value
            var alertSignatureIdCell = _(rowData.cells).find(function (cell) {
               return cell.field === 'alert.signature_id';
            });
            //update the search with the sourcetype that we are interested in
            this._searchManager.set({ search: 'source="*suricata*" event_type="alert" alert.signature_id=' + alertSignatureIdCell.value });
            // $container is the jquery object where we can put out content.
            // In this case we will render our chart and add it to the $container
            $container.append(this._eventsViewer.render().el);
        }
    });
    var tableElement = mvc.Components.getInstance("expand_with_events");
    tableElement.getVisualization(function(tableView) {
        // Add custom cell renderer, the table will re-render automatically.
        tableView.addRowExpansionRenderer(new EventSearchBasedRowExpansionRenderer());
    });
});
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;As you can see, the table depends on a time input  (token &lt;CODE&gt;TimeRangePicker&lt;/CODE&gt;) that I am also trying to integrate in the javascript. I have already tried to write something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;require([
    'splunkjs/mvc/tableview',
    'splunkjs/mvc/eventsviewerview',
    'splunkjs/mvc/searchmanager',
    'splunkjs/mvc',
    'underscore',
    'splunkjs/mvc/simplexml/ready!'],function(
    TableView,
    EventsViewer,
    SearchManager,
    mvc,
    _
    ){
    var EventSearchBasedRowExpansionRenderer = TableView.BaseRowExpansionRenderer.extend({
        initialize: function(args) {
            // initialize will run once, so we will set up a search and a chart to be reused.
            this._searchManager = new SearchManager({
                id: 'details-search-manager',
                preview: false
            });
            this._eventsViewer = new EventsViewer({
                managerid: 'details-search-manager'
            });
        },
        canRender: function(rowData) {
            // Since more than one row expansion renderer can be registered we let each decide if they can handle that
            // data
            // Here we will always handle it.
            return true;
        },
        render: function($container, rowData) {
            // rowData contains information about the row that is expanded.  We can see the cells, fields, and values
            // We will find the sourcetype cell to use its value
            var alertSignatureIdCell = _(rowData.cells).find(function (cell) {
               return cell.field === 'alert.signature_id';
            });
            //update the search with the sourcetype that we are interested in
            this._searchManager.set({
                search: 'source="*suricata*" event_type="alert" alert.signature_id=' + alertSignatureIdCell.value,
                earliest_time: $TimeRangePicker.earliest$,
                latest_time: $TimeRangePicker.latest$
            });
            // $container is the jquery object where we can put out content.
            // In this case we will render our chart and add it to the $container
            $container.append(this._eventsViewer.render().el);
        }
    });
    var tableElement = mvc.Components.getInstance("expand_with_events");
    tableElement.getVisualization(function(tableView) {
        // Add custom cell renderer, the table will re-render automatically.
        tableView.addRowExpansionRenderer(new EventSearchBasedRowExpansionRenderer());
    });
});
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But now, rows don't expand and the web console says &lt;CODE&gt;$TimeRangePicker&lt;/CODE&gt; is not defined.&lt;/P&gt;

&lt;P&gt;How can I integrate the time constraint from my time input in the javascript?&lt;/P&gt;

&lt;P&gt;Thank you in advance for your help.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Apr 2016 07:15:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-integrate-the-time-constraint-from-my-time-input-token/m-p/219140#M64409</guid>
      <dc:creator>sebdamaye</dc:creator>
      <dc:date>2016-04-21T07:15:30Z</dc:date>
    </item>
    <item>
      <title>Re: How can I integrate the time constraint from my time input token in JavaScript for a table with expandable rows?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-integrate-the-time-constraint-from-my-time-input-token/m-p/219141#M64410</link>
      <description>&lt;P&gt;On line 40 and 41, surrounding variables with quotes removes the error but it still does not filter events with time selected from my input:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;earliest_time: "$TimeRangePicker.earliest$",
latest_time: "$TimeRangePicker.latest$"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 21 Apr 2016 17:03:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-integrate-the-time-constraint-from-my-time-input-token/m-p/219141#M64410</guid>
      <dc:creator>sebdamaye</dc:creator>
      <dc:date>2016-04-21T17:03:33Z</dc:date>
    </item>
    <item>
      <title>Re: How can I integrate the time constraint from my time input token in JavaScript for a table with expandable rows?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-integrate-the-time-constraint-from-my-time-input-token/m-p/219142#M64411</link>
      <description>&lt;P&gt;You could try this instead&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;var t=TimeRangePicker.val();
var te=t.earliest_time;  
var tl=t.latest_time; 

earliest_time: te
latest_time: tl
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 21 Apr 2016 18:17:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-integrate-the-time-constraint-from-my-time-input-token/m-p/219142#M64411</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-04-21T18:17:36Z</dc:date>
    </item>
    <item>
      <title>Re: How can I integrate the time constraint from my time input token in JavaScript for a table with expandable rows?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-integrate-the-time-constraint-from-my-time-input-token/m-p/219143#M64412</link>
      <description>&lt;P&gt;Thank you for helping @sundareshr. I have tried as follows but it now claims TimeRangePicker is not defined. Maybe I haven't placed your code at the appropriate place?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;require([
    'splunkjs/mvc/tableview',
    'splunkjs/mvc/eventsviewerview',
    'splunkjs/mvc/searchmanager',
    'splunkjs/mvc',
    'underscore',
    'splunkjs/mvc/simplexml/ready!'],function(
    TableView,
    EventsViewer,
    SearchManager,
    mvc,
    _
    ){
    var EventSearchBasedRowExpansionRenderer = TableView.BaseRowExpansionRenderer.extend({
        initialize: function(args) {
            // initialize will run once, so we will set up a search and a chart to be reused.
            this._searchManager = new SearchManager({
                id: 'details-search-manager',
                preview: false
            });
            this._eventsViewer = new EventsViewer({
                managerid: 'details-search-manager'
            });
        },
        canRender: function(rowData) {
            // Since more than one row expansion renderer can be registered we let each decide if they can handle that
            // data
            // Here we will always handle it.
            return true;
        },
        render: function($container, rowData) {
            // rowData contains information about the row that is expanded.  We can see the cells, fields, and values
            // We will find the sourcetype cell to use its value
            var alertSignatureIdCell = _(rowData.cells).find(function (cell) {
               return cell.field === 'alert.signature_id';
            });
            //update the search with the sourcetype that we are interested in
            var t=TimeRangePicker.val();
            var te=t.earliest_time;
            var tl=t.latest_time;
            this._searchManager.set({
                search: 'source="*suricata*" event_type="alert" alert.signature_id=' + alertSignatureIdCell.value,
                earliest_time: te,
                latest_time: tl
            });
            // $container is the jquery object where we can put out content.
            // In this case we will render our chart and add it to the $container
            $container.append(this._eventsViewer.render().el);
        }
    });
    var tableElement = mvc.Components.getInstance("expand_with_events");
    tableElement.getVisualization(function(tableView) {
        // Add custom cell renderer, the table will re-render automatically.
        tableView.addRowExpansionRenderer(new EventSearchBasedRowExpansionRenderer());
    });
});
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 21 Apr 2016 18:27:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-integrate-the-time-constraint-from-my-time-input-token/m-p/219143#M64412</guid>
      <dc:creator>sebdamaye</dc:creator>
      <dc:date>2016-04-21T18:27:26Z</dc:date>
    </item>
    <item>
      <title>Re: How can I integrate the time constraint from my time input token in JavaScript for a table with expandable rows?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-integrate-the-time-constraint-from-my-time-input-token/m-p/219144#M64413</link>
      <description>&lt;P&gt;You need to define the &lt;CODE&gt;TimeRangePicker&lt;/CODE&gt; object. Just like you did for the &lt;CODE&gt;tableView&lt;/CODE&gt; object. So add this &lt;CODE&gt;var TimeRangePicker=mvc.Components.getInstance("TimeRangePicker"); , before&lt;/CODE&gt;var t=TimeRangePicker.val();`&lt;/P&gt;</description>
      <pubDate>Thu, 21 Apr 2016 18:36:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-integrate-the-time-constraint-from-my-time-input-token/m-p/219144#M64413</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-04-21T18:36:28Z</dc:date>
    </item>
    <item>
      <title>Re: How can I integrate the time constraint from my time input token in JavaScript for a table with expandable rows?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-integrate-the-time-constraint-from-my-time-input-token/m-p/219145#M64414</link>
      <description>&lt;P&gt;Very weird.... wherever I add &lt;CODE&gt;var TimeRangePicker=mvc.Components.getInstance("TimeRangePicker");&lt;/CODE&gt; it says that TimeRangePicker is undefined. I also tried to use &lt;CODE&gt;PostProcessManager&lt;/CODE&gt; as described here (&lt;A href="http://dev.splunk.com/view/webframework-developapps/SP-CAAAEM8"&gt;http://dev.splunk.com/view/webframework-developapps/SP-CAAAEM8&lt;/A&gt;) to filter results based on time constraint after the search but it's not working either. It seems that the issue is actually that the javascript is not able to get the value from the &lt;CODE&gt;TimeRangePicker&lt;/CODE&gt; token. However my input has the correct token name. Now trying to use &lt;CODE&gt;tokenSafe&lt;/CODE&gt; as described here: &lt;A href="http://dev.splunk.com/view/SP-CAAAEVR"&gt;http://dev.splunk.com/view/SP-CAAAEVR&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Apr 2016 19:53:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-integrate-the-time-constraint-from-my-time-input-token/m-p/219145#M64414</guid>
      <dc:creator>sebdamaye</dc:creator>
      <dc:date>2016-04-21T19:53:44Z</dc:date>
    </item>
    <item>
      <title>Re: How can I integrate the time constraint from my time input token in JavaScript for a table with expandable rows?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-integrate-the-time-constraint-from-my-time-input-token/m-p/219146#M64415</link>
      <description>&lt;P&gt;Looks like I'm missing something here... &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;BR /&gt;
I've tried the following code with &lt;CODE&gt;tokenSafe&lt;/CODE&gt;. It does not produce any error but does not filter on time selected from the &lt;CODE&gt;TimeRangePicker&lt;/CODE&gt; input.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;require([
        'splunkjs/mvc/tableview',
        'splunkjs/mvc/eventsviewerview',
        'splunkjs/mvc/searchmanager',
        'splunkjs/mvc',
        'underscore',
        'splunkjs/mvc/simplexml/ready!'
    ],function(
        TableView,
        EventsViewer,
        SearchManager,
        mvc,
        _
    ){
    var EventSearchBasedRowExpansionRenderer = TableView.BaseRowExpansionRenderer.extend({
        initialize: function(args) {
            // initialize will run once, so we will set up a search and a chart to be reused.
            this._searchManager = new SearchManager({
                id: 'details-search-manager',
                preview: false
            });
            this._eventsViewer = new EventsViewer({
                managerid: 'details-search-manager'
            });
        },
        canRender: function(rowData) {
            // Since more than one row expansion renderer can be registered we let each decide if they can handle that
            // data
            // Here we will always handle it.
            return true;
        },
        render: function($container, rowData) {
            // rowData contains information about the row that is expanded.  We can see the cells, fields, and values
            // We will find the sourcetype cell to use its value
            var alertSignatureIdCell = _(rowData.cells).find(function (cell) {
               return cell.field === 'alert.signature_id';
            });
            //update the search with the sourcetype that we are interested in
            this._searchManager.set({
                search: 'source="*suricata*" event_type="alert" alert.signature_id=' + alertSignatureIdCell.value,
                earliest_time: mvc.tokenSafe('$TimeRangePicker.earliest_time$'),
                latest_time: mvc.tokenSafe('$TimeRangePicker.latest_time$')
            });
            // $container is the jquery object where we can put out content.
            // In this case we will render our chart and add it to the $container
            $container.append(this._eventsViewer.render().el);
        }
    });
    var tableElement = mvc.Components.getInstance("expand_with_events");
    tableElement.getVisualization(function(tableView) {
        // Add custom cell renderer, the table will re-render automatically.
        tableView.addRowExpansionRenderer(new EventSearchBasedRowExpansionRenderer());
    });

});
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Help....&lt;/P&gt;</description>
      <pubDate>Thu, 21 Apr 2016 20:53:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-integrate-the-time-constraint-from-my-time-input-token/m-p/219146#M64415</guid>
      <dc:creator>sebdamaye</dc:creator>
      <dc:date>2016-04-21T20:53:58Z</dc:date>
    </item>
    <item>
      <title>Re: How can I integrate the time constraint from my time input token in JavaScript for a table with expandable rows?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-integrate-the-time-constraint-from-my-time-input-token/m-p/219147#M64416</link>
      <description>&lt;P&gt;I HAVE DONE IT!!! After 2 days of struggling with JavaScript debugging, I've finally found the solution. Here is how I did: I converted my dashboard from XML to HTML and analyzed how the search was impacted by the time picker. I noticed that the &lt;CODE&gt;earliest_time&lt;/CODE&gt; and &lt;CODE&gt;latest_time&lt;/CODE&gt; fields were actually fed with &lt;CODE&gt;$form.TimeRangePicker.earliest$&lt;/CODE&gt; and &lt;CODE&gt;$form.TimeRangePicker.latest&lt;/CODE&gt; with &lt;CODE&gt;tokens&lt;/CODE&gt; set to &lt;CODE&gt;true&lt;/CODE&gt;. Below is my final code:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;require([
        'splunkjs/mvc/tableview',
        'splunkjs/mvc/eventsviewerview',
        'splunkjs/mvc/searchmanager',
        'splunkjs/mvc',
        'underscore',
        'splunkjs/mvc/simplexml/ready!'
    ],function(
        TableView,
        EventsViewer,
        SearchManager,
        mvc,
        _
    ){
    var EventSearchBasedRowExpansionRenderer = TableView.BaseRowExpansionRenderer.extend({
        initialize: function(args) {
            // initialize will run once, so we will set up a search and a chart to be reused.
            this._searchManager = new SearchManager({
                id: 'details-search-manager',
                preview: false
            });
            this._eventsViewer = new EventsViewer({
                managerid: 'details-search-manager'
            });
        },
        canRender: function(rowData) {
            // Since more than one row expansion renderer can be registered we let each decide if
            // they can handle that data
            // Here we will always handle it.
            return true;
        },
        render: function($container, rowData) {
            // rowData contains information about the row that is expanded.  We can see the cells, fields, and values
            // We will find the sourcetype cell to use its value
            var alertSignatureIdCell = _(rowData.cells).find(function (cell) {
               return cell.field === 'alert.signature_id';
            });
            //update the search with the sourcetype that we are interested in
            this._searchManager.set({
                earliest_time: "$form.TimeRangePicker.earliest$",
                latest_time: "$form.TimeRangePicker.latest$",
                search: 'source="*suricata*" event_type="alert" alert.signature_id=' + alertSignatureIdCell.value
            }, {tokens: true});
            // $container is the jquery object where we can put out content.
            // In this case we will render our chart and add it to the $container
            $container.append(this._eventsViewer.render().el);
        }
    });
    var tableElement = mvc.Components.getInstance("expand_with_events");
    tableElement.getVisualization(function(tableView) {
        // Add custom cell renderer, the table will re-render automatically.
        tableView.addRowExpansionRenderer(new EventSearchBasedRowExpansionRenderer());
    });

});
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 22 Apr 2016 18:41:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-integrate-the-time-constraint-from-my-time-input-token/m-p/219147#M64416</guid>
      <dc:creator>sebdamaye</dc:creator>
      <dc:date>2016-04-22T18:41:45Z</dc:date>
    </item>
  </channel>
</rss>

