Facility Control

 View Only
  • 1.  Simple Grid - Single Selection

    Posted 03-01-2017 13:34

    Hi, I have created a simple grid with 50 toggles. I would like to only have one button selected at a time. Is there away to do this. Attached is a picture of the router control I am working on. You can see that multiple source can be selected at once and I do not want that. New to this coding thing. Just trying to learn one process at a time.



  • 2.  RE: Simple Grid - Single Selection

    Posted 03-01-2017 13:47

    Your best approach is to use a parameter with a choice constraint and a radio toggle widget hint. You can attach a task to the parameter to react when a new value is selected.
    In my example, I have included an additional script that runs when the panel loads to clear any existing selection.

    <abs contexttype="opengear" style="">
       <meta>
          <ogscript handles="onload">params.setValue('params.toggle', 0, -1);</ogscript>
          <params>
             <param access="1" constrainttype="INT_CHOICE" name="Toggle Buttons" oid="params.toggle" precision="0" type="INT16" value="-1" widget="radio-toggle">
                <constraint key="0">Button 1</constraint>
                <constraint key="1">Button 2</constraint>
                <constraint key="2">...</constraint>
                <constraint key="3"/>
                <constraint key="4"/>
                <constraint key="5"/>
                <constraint key="6"/>
                <constraint key="7"/>
                <constraint key="8"/>
                <constraint key="9"/>
                <constraint key="10"/>
                <constraint key="11"/>
                <constraint key="12"/>
                <constraint key="13"/>
                <constraint key="14"/>
                <constraint key="15"/>
                <constraint key="16"/>
                <constraint key="17"/>
                <constraint key="18"/>
                <constraint key="19"/>
                <constraint key="20"/>
                <constraint key="21"/>
                <constraint key="22"/>
                <constraint key="23"/>
                <constraint key="24"/>
                <constraint key="25"/>
                <constraint key="26"/>
                <constraint key="27"/>
                <constraint key="28"/>
                <constraint key="29"/>
                <constraint key="30"/>
                <constraint key="31"/>
                <constraint key="32"/>
                <constraint key="33"/>
                <constraint key="34"/>
                <constraint key="35"/>
                <constraint key="36"/>
                <constraint key="37"/>
                <constraint key="38"/>
                <constraint key="39"/>
                <constraint key="40"/>
                <constraint key="41"/>
                <constraint key="42"/>
                <constraint key="43"/>
                <constraint key="44"/>
                <constraint key="45"/>
                <constraint key="46"/>
                <constraint key="47"/>
                <constraint key="48"/>
                <constraint key="49"/>
             </param>
          </params>
       </meta>
       <simplegrid bottom="8" cols="10" left="6" right="8" top="6">
          <param expand="true" oid="params.toggle" style="style:toggleButton;">
             <task tasktype="ogscript">if (this.getValue() &lt; 0)
    {
       //NO SELECTION
       return;
    }
    
    if (this.getValue() == 0)
    {
       ogscript.debug("BUTTON TASK 1");
    }
    else if (this.getValue() == 1)
    {
       ogscript.debug("BUTTON TASK 2");
    }
    else
    {
       ogscript.debug("BUTTON " + (this.getValue() + 1));
    }
    
    </task>
          </param>
       </simplegrid>
    </abs>

    #DashBoard