Facility Control

 View Only
  • 1.  Making Time Picker Read Only

    Posted 02-20-2018 15:02
    Hey all,

    I was wondering if anyone knows a way to make a Time Picker widget read only? Basically the user will select an option from a dropdown menu and based on the value of the dropdown it will make a Time Picker either read/write or Read only.

    Thanks!


  • 2.  RE: Making Time Picker Read Only

    Posted 02-20-2018 17:29

    Hi
    Try this as an idea. I have 2 param on the UI that are on top of one another, one is editable the other not. I then have a couple of buttons (or whatever in your code) to reveal or hide as required.
    This uses an attribute on a param called editable, but I couldn't figure out a way to programatically change it. Using the %value% method didn't work.
    Simon

    <abs contexttype="opengear">
    <meta>
    <params>
    <param access="1" maxlength="0" name="Test" oid="Time" type="STRING" value="01:06:01" widget="time-picker"/>
    </params>
    </meta>
    <abs height="50" id="ReadOnly" left="100" top="100">
    <param editable="false" expand="true" left="0" oid="Time" showlabel="false" style="size:Big" top="0" width="100"/>
    </abs>
    <abs height="50" id="ReadWrite" left="100" top="100">
    <param editable="true" expand="true" left="0" oid="Time" showlabel="false" style="size:Big" top="0" width="100"/>
    </abs>
    <button buttontype="push" height="34" id="" left="218" name="Read Only" top="94" width="108">
    <task tasktype="ogscript">ogscript.hide('ReadWrite');
    ogscript.reveal('ReadOnly');</task>
    </button>
    <button buttontype="push" height="29" left="340" name="Read/Write" top="97" width="114">
    <task tasktype="ogscript">ogscript.reveal('ReadWrite');
    ogscript.hide('ReadOnly');</task>
    </button>
    </abs>

    #DashBoard


  • 3.  RE: Making Time Picker Read Only

    Posted 02-20-2018 19:48

    You can use params.setAccess(OID, value); where a value of 0 = read only and a value of 1 = read/write.

    <abs contexttype="opengear">
       <meta>
          <params>
             <param access="1" maxlength="0" name="Test" oid="Time" type="STRING" value="01:06:01" widget="time-picker"/>
             <param access="1" constrainttype="INT_CHOICE" name="Editable" oid="Editable" precision="0" type="INT32" value="0" widget="checkbox">
                <constraint key="0">Read Only</constraint>
                <constraint key="1">Editable</constraint>
             </param>
          </params>
       </meta>
       <param expand="true" height="53" left="49" oid="Time" showlabel="false" style="size:Big" top="30" width="185"/>
       <param expand="true" height="40" left="265" oid="Editable" runtasksonload="true" top="37" width="41">
          <task tasktype="ogscript">params.setAccess('Time', params.getValue('Editable', 0)); //0 = read only, 1 = read/write</task>
       </param>
    </abs>
    

    #DashBoard


  • 4.  RE: Making Time Picker Read Only

    Posted 02-21-2018 13:52
    Thanks James and Simonl, I just saw this so I tried James's method first and it worked great.
    #DashBoard


  • 5.  RE: Making Time Picker Read Only

    Posted 02-21-2018 14:27

    Hey James, I did run into one issue. When I go into Panel builder mode and I edit any object in the panel, then "Apply and Close" it changes the widget. When I change param (a) to set it back to editable it stays Read-Only until I refresh the page (F5). See attached screenshots.


    #DashBoard


  • 6.  RE: Making Time Picker Read Only

    Posted 02-21-2018 18:32

    I specify the hint in the parameter. I have an API set up to trigger the read only, then in each drop down menu I reference that API on change, it also take affect on load. Right now I have 2 params that are stuck on read only. I had to go into the "source" code of the param and add back in access. See below examples.

    Working Param

    <param access="1" colspan="1" expand="true" fill="both" maxlength="0" oid="S.START.01" precision="0" rowspan="1" weightx="1.0" weighty="1.0">
                      <config key="w.format">HH:mm</config>
                      <config key="w.restricted">true</config>
                      <task tasktype="ogscript">updateSchedulerArrays();</task>
                      <task tasktype="ogscript">%const['GlobalFunctions']['SetTime']%
    SetTime()</task>
                   </param>

    Non-working Param

    <param colspan="1" expand="true" fill="both" oid="S.START.05" precision="0" rowspan="1" weightx="1.0" weighty="1.0">
                      <config key="w.format">HH:mm</config>
                      <config key="w.restricted">true</config>
                      <task tasktype="ogscript">updateSchedulerArrays();</task>
                      <task tasktype="ogscript">%const['GlobalFunctions']['SetTime']%
    SetTime()</task>
                   </param>               

    #DashBoard