All Apps and Add-ons

How to preserve template in checkboxes module and set checkboxes checked by default

royimad
Builder

I need to draw and populate a list of checkboxes dynamically from a search using sideview.
The following code will fill those checkboxes, what i need is that those checkboxes are checked by default and to preserve all the values in "test2" parameter ( all the selected values )

The code is the above:

<view autoCancelInterval="90" isVisible="True" onunloadCancelJobs="true" template="dashboard.html" isSticky="False">
  <label>Uptime Explorer</label>
  <module name="AccountBar" layoutPanel="appHeader" />
  <module name="AppBar" layoutPanel="appHeader" />
  <module name="SideviewUtils" layoutPanel="appHeader" />


  <module name="Message" layoutPanel="messaging">
    <param name="filter">*</param>
    <param name="maxSize">2</param>
    <param name="clearOnJobDispatch">False</param>
  </module>


  <module name="HTML" layoutPanel="viewHeader">
    <param name="html"><![CDATA[
    <h1>Uptime Explorer</h1>
    ]]></param>
  </module>


  <module name="URLLoader" layoutPanel="panel_row1_col1" autoRun="True">
    <param name="keepURLUpdated">True</param>

      <module name="TimeRangePicker" layoutpanel="panel_row2_col2" group="Second Group">
        <param name="default">Last 15 minutes</param>

        <module name="Search" layoutPanel="panel_row2_col1" group="Select a Series and a Locations" autoRun="true">
          <param name="search"><![CDATA[
           |savedsearch Devices_Locations | eval DeviceId=DeviceId | stats values(Location) as name  | fields - count | mvexpand name | eval value=name | fields - name
          ]]></param>



          <module name="Checkboxes">
            <param name="name">test2</param>
            <param name="valueField">value</param>
            <param name="labelField">label</param>
            <param name="separator">+OR+</param> 
            <param name="template">Location="$value$"</param>
            <param name="outerTemplate">( $value$ )</param>

            <module name="Button" layoutpanel="panel_row2_col2" group="Second Group">

              <module name="Search" layoutPanel="panel_row2_col2" group="Second Group" autoRun="False" >
                <param name="search" autoRun="False"><![CDATA[
                  |savedsearch Devices_Locations | where $test2$ | stats values(DeviceId) as DeviceId  | fields DeviceId  ]]>      
                </param>

                <module name="Table">
                  <param name="count">1000</param>
                </module>
              </module>
            </module>   
          </module>   
        </module>
      </module>
    </module>

</view>
1 Solution

sideview
SplunkTrust
SplunkTrust

It's no problem. It works just like the Pulldown module as far as how you prepopulate the selections - you use a ValueSetter.

As far as having the users selection remain selected, the URLLoader will keep them selected so if they use the back button to return to the page, or if they reload the page in their browser, it'll still be in the state it was when they left the page. As far as remembering selection state across selections, we don't have a way to do that yet, but it's not as commonly asked for so hopefully you're not asking about that.

So put this ValueSetter upstream from the Pulldown and downstream from the URLLoader.

<module name="ValueSetter">
  <param name="name">test2</param>
  <param name="value">fooValue,barValue</param>
  <param name="delim">,</param>
  <param name="allowClobber">False</param>

It says to select the "fooValue" and "barValue" checkboxes. It also sets allowClobber to false, which will mean in this case, if the URLLoader has already set it from upstream, the URLLoader is boss and the ValueSetter will do nothing. Since keepUrlUpdated is set to True, this in turn means the URLLoader will set the value in the URL as soon as the Checkboxes are interacted with, so in practice the ValueSetter will only set the default the first time the page loads.

You can read more about ValueSetter's uses, including all these less commonly used params delim and allowClobber, in the ValueSetter docs page in Sideview Utils itself. The Pulldown may need a cross reference to the ValueSetter page for the prepopulation question and assuming that's not there already I'll add it to the docs for the next release.

View solution in original post

sideview
SplunkTrust
SplunkTrust

WARNING: Roy you should take all those extra autoRun attributes out of this view. Those can cause havoc. take all of them out except the autoRun="True" on the URLLoader. The autoRun="False" attributes are completely meaningless and should always be removed when you see them. They are evil because someone else will see them and think they mean something.

And putting autoRun="True" on a module that is nested inside another module that already has an autoRun="True" is redundant, but in a very dangerous way in that it also causes very strange things to happen.

0 Karma

sideview
SplunkTrust
SplunkTrust

It's no problem. It works just like the Pulldown module as far as how you prepopulate the selections - you use a ValueSetter.

As far as having the users selection remain selected, the URLLoader will keep them selected so if they use the back button to return to the page, or if they reload the page in their browser, it'll still be in the state it was when they left the page. As far as remembering selection state across selections, we don't have a way to do that yet, but it's not as commonly asked for so hopefully you're not asking about that.

So put this ValueSetter upstream from the Pulldown and downstream from the URLLoader.

<module name="ValueSetter">
  <param name="name">test2</param>
  <param name="value">fooValue,barValue</param>
  <param name="delim">,</param>
  <param name="allowClobber">False</param>

It says to select the "fooValue" and "barValue" checkboxes. It also sets allowClobber to false, which will mean in this case, if the URLLoader has already set it from upstream, the URLLoader is boss and the ValueSetter will do nothing. Since keepUrlUpdated is set to True, this in turn means the URLLoader will set the value in the URL as soon as the Checkboxes are interacted with, so in practice the ValueSetter will only set the default the first time the page loads.

You can read more about ValueSetter's uses, including all these less commonly used params delim and allowClobber, in the ValueSetter docs page in Sideview Utils itself. The Pulldown may need a cross reference to the ValueSetter page for the prepopulation question and assuming that's not there already I'll add it to the docs for the next release.

royimad
Builder

can ValueSetter could be populated with the same search as the checkboxes module? so i will use value inside a value setter instead of listing all the values one by one?

0 Karma
Get Updates on the Splunk Community!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...