<?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: Splunk 6 Web Framework: setting the initial value of a TimeRangeView after page load in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/Splunk-6-Web-Framework-setting-the-initial-value-of-a/m-p/131869#M7770</link>
    <description>&lt;P&gt;Thanks - "settings.set" is certainly better; I would have used it if it were documented!&lt;BR /&gt;
Your script shows a nice workaround to having a preset and a custom timerange. Would it be correct to say that a preset configured in Django cannot be overwritten in JavaScript?&lt;/P&gt;</description>
    <pubDate>Tue, 04 Feb 2014 13:29:02 GMT</pubDate>
    <dc:creator>helge</dc:creator>
    <dc:date>2014-02-04T13:29:02Z</dc:date>
    <item>
      <title>Splunk 6 Web Framework: setting the initial value of a TimeRangeView after page load</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Splunk-6-Web-Framework-setting-the-initial-value-of-a/m-p/131867#M7768</link>
      <description>&lt;P&gt;I am passing URL parameters to a view built with Django and the web framework in Splunk 6. Among those paramters are the earliest and latest time, which I need to apply to the TimeRangeView on the page. That works, too, but only if the timerange does not have a preset. If if does, the value my code sets is overwritten a few hundred milliseconds later by the preset value.&lt;/P&gt;

&lt;P&gt;This is my code:&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;&lt;P&gt;content block:&lt;/P&gt;

&lt;P&gt;{% timerange id="timerange1" managerid="search1" preset="Today" earliest_time="$earlyval$"|token_safe latest_time="$lateval$"|token_safe %}&lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;P&gt;js block:&lt;/P&gt;

&lt;P&gt;var deps =&lt;BR /&gt;
[&lt;BR /&gt;
   "splunkjs/ready!",&lt;BR /&gt;
   "splunkjs/mvc/timerangeview"&lt;BR /&gt;
];&lt;BR /&gt;
require(deps, function(mvc)&lt;BR /&gt;
{&lt;BR /&gt;
   // Get the parameters&lt;BR /&gt;
   var paramEarliest = getParameterByName("earliest");&lt;BR /&gt;
   var paramLatest = getParameterByName("latest");&lt;/P&gt;

&lt;P&gt;// Set the timerange&lt;BR /&gt;
   if (paramEarliest != "" &amp;amp;&amp;amp; paramLatest != "")&lt;BR /&gt;
   {&lt;BR /&gt;
      var timerange = splunkjs.mvc.Components.getInstance("timerange1");&lt;BR /&gt;
      timerange.settings.set("value", {"earliest_time" : paramEarliest, "latest_time" : paramLatest});&lt;BR /&gt;
   }&lt;BR /&gt;
});&lt;/P&gt;&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;&lt;STRONG&gt;How can wait until the preset has been applied before I set my custom values?&lt;BR /&gt;
Alternatively: how can I disable the preset in my script?&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 15:46:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Splunk-6-Web-Framework-setting-the-initial-value-of-a/m-p/131867#M7768</guid>
      <dc:creator>helge</dc:creator>
      <dc:date>2020-09-28T15:46:30Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk 6 Web Framework: setting the initial value of a TimeRangeView after page load</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Splunk-6-Web-Framework-setting-the-initial-value-of-a/m-p/131868#M7769</link>
      <description>&lt;P&gt;I've coded up a sample that conditionally either sets a preset or sets a specific value:&lt;BR /&gt;
&lt;A href="https://gist.github.com/davidfstr/eb7fdf952d4648b4957c"&gt;https://gist.github.com/davidfstr/eb7fdf952d4648b4957c&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;In general you should be using &lt;CODE&gt;timerange.settings&lt;/CODE&gt; to alter the properties of a TimeRangeView (or any component) after it is initialized. Any underscore-prefixed field or method like &lt;CODE&gt;timerange._state&lt;/CODE&gt; is private and may change without warning in future framework versions.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Feb 2014 18:53:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Splunk-6-Web-Framework-setting-the-initial-value-of-a/m-p/131868#M7769</guid>
      <dc:creator>dfoster_splunk</dc:creator>
      <dc:date>2014-02-03T18:53:18Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk 6 Web Framework: setting the initial value of a TimeRangeView after page load</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Splunk-6-Web-Framework-setting-the-initial-value-of-a/m-p/131869#M7770</link>
      <description>&lt;P&gt;Thanks - "settings.set" is certainly better; I would have used it if it were documented!&lt;BR /&gt;
Your script shows a nice workaround to having a preset and a custom timerange. Would it be correct to say that a preset configured in Django cannot be overwritten in JavaScript?&lt;/P&gt;</description>
      <pubDate>Tue, 04 Feb 2014 13:29:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Splunk-6-Web-Framework-setting-the-initial-value-of-a/m-p/131869#M7770</guid>
      <dc:creator>helge</dc:creator>
      <dc:date>2014-02-04T13:29:02Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk 6 Web Framework: setting the initial value of a TimeRangeView after page load</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Splunk-6-Web-Framework-setting-the-initial-value-of-a/m-p/131870#M7771</link>
      <description>&lt;P&gt;I replaced timerange._state with timerange.settings in the question.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Feb 2014 13:32:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Splunk-6-Web-Framework-setting-the-initial-value-of-a/m-p/131870#M7771</guid>
      <dc:creator>helge</dc:creator>
      <dc:date>2014-02-04T13:32:21Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk 6 Web Framework: setting the initial value of a TimeRangeView after page load</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Splunk-6-Web-Framework-setting-the-initial-value-of-a/m-p/131871#M7772</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;Would it be correct to say that a preset configured in Django cannot be overwritten in JavaScript?&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;It should be reconfigurable. The original code was actually hitting an unrelated bug that prevented changes to {earliest_time, latest_time} during initialization time if no "value" property was set. This bug should be fixed in the next Splunk release.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 15:48:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Splunk-6-Web-Framework-setting-the-initial-value-of-a/m-p/131871#M7772</guid>
      <dc:creator>dfoster_splunk</dc:creator>
      <dc:date>2020-09-28T15:48:08Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk 6 Web Framework: setting the initial value of a TimeRangeView after page load</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Splunk-6-Web-Framework-setting-the-initial-value-of-a/m-p/131872#M7773</link>
      <description>&lt;P&gt;You're right about view.settings not being documented. It should be. I'll get on that.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Feb 2014 18:01:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Splunk-6-Web-Framework-setting-the-initial-value-of-a/m-p/131872#M7773</guid>
      <dc:creator>dfoster_splunk</dc:creator>
      <dc:date>2014-02-04T18:01:14Z</dc:date>
    </item>
  </channel>
</rss>

