Facility Control

 View Only
  • 1.  Change toggle buttons amount with replaceConstraint - its a bug?

    Posted 05-24-2020 20:20

    Hello Ross support,

    I feel like i write too much on forum those days, sorry)

    I found something strange: i have string choice constraint, with 3 values - so i see them as 3 buttons. now i want to change the values - ok, i create new array, and change it with another 3 values. Until now all good. So, now i want to replace it with new constraint that include 4 values instead of 3. And nothing happened. I tried also intChoice with same result. Now i believe its not about the constraint type - its about "toggle buttons" widget. Because in "list" widget its work as expected. So, i miss something, or this is an new release bug? Unfortunately, i dont have lower DB version right now, so i cant test it on prev. version DB.

    Note i running Dashboard 9.02. I just prepared an example so you can see it by yourself:

     

    <abs contexttype="opengear" gridsize="20" id="_top">
    <meta>
    <params>
    <param access="1" constrainttype="STRING_CHOICE" maxlength="0" name="toggle" oid="toggle" type="STRING" value="basda" widget="radio-toggle">
    <constraint>asd</constraint>
    <constraint>basda</constraint>
    <constraint>hjk</constraint>
    </param>
    <param access="1" constrainttype="INT_CHOICE" name="list" oid="list" precision="0" type="INT32" value="5" widget="list">
    <constraint key="0">cam1</constraint>
    <constraint key="1">cam2</constraint>
    <constraint key="5">cam3</constraint>
    </param>
    </params>
    </meta>
    <meta/>





    <param expand="true" height="140" left="240" oid="toggle" style="style:toggleButton;" top="140" width="600"/>
    <button buttontype="push" height="40" left="420" name="3 Letters" top="380" width="100">
    <task tasktype="ogscript">var choices = new Array();
    choices[0] = 'One';
    choices[1] = 'Two';
    choices[2] = 'three';


    var newCon = params.createStringChoiceConstraint(choices);
    params.replaceConstraint("toggle", newCon);</task>
    </button>
    <param expand="true" height="400" left="1420" oid="list" top="320" width="260"/>
    <button buttontype="push" height="40" left="520" name="3 Numbers" top="380" width="100">
    <task tasktype="ogscript">var choices = new Array();
    choices[0] = '12';
    choices[1] = '13';
    choices[2] = '14';


    var newCon = params.createStringChoiceConstraint(choices);
    params.replaceConstraint("toggle", newCon);</task>
    </button>
    <label height="40" left="40" name="While changing the same amounth of values, no problem" style="txt-align:west;" top="380" width="340"/>
    <label height="40" left="40" name="What happenes now? changing the amounth of values to 4" style="txt-align:west;" top="440" width="360"/>
    <button buttontype="push" height="40" left="420" name="4 Letters" top="440" width="100">
    <task tasktype="ogscript">var choices = new Array();
    choices[0] = 'One';
    choices[1] = 'Two';
    choices[2] = 'three';
    choices[3] = 'four';

    var newCon = params.createStringChoiceConstraint(choices);
    params.replaceConstraint("toggle", newCon);</task>
    </button>
    <button buttontype="push" height="40" left="520" name="4 Numbers" top="440" width="100">
    <task tasktype="ogscript">var choices = new Array();
    choices[0] = '12';
    choices[1] = '13';
    choices[2] = '14';
    choices[3] = '15';

    var newCon = params.createStringChoiceConstraint(choices);
    params.replaceConstraint("toggle", newCon);</task>
    </button>
    <label height="60" left="240" name="Simple string choice constrint" style="txt-align:center" top="60" width="600"/>
    </abs>


  • 2.  RE: Change toggle buttons amount with replaceConstraint - its a bug?

    Posted 05-25-2020 20:51

    Hi Alex

    When you change the number of controls needed to draw the parameter, DashBoard will always rebuild the container the parameter is in. If you put the parameter directly on the panel's top-level container, you will see the issue you are describing  (since the parameter itself is defined inside of that container and is getting destroyed/re-created).

    The solution is to put the buttons inside of a container that can be rebuilt without taking-out your parameter. In this case, I've put your buttons inside of a <simplegrid/> with a single row to replicate the UI you had already drawn. When I change the number of choices, the <simplegrid> will be silently rebuilt but the top-level <abs/> and the parameter itself are unchanged.

     

    <abs contexttype="opengear" gridsize="20" id="_top">
    <meta>
    <params>
    <param access="1" constrainttype="STRING_CHOICE" maxlength="0" name="toggle" oid="toggle" type="STRING" value="basda" widget="radio-toggle">
    <constraint>asd</constraint>
    <constraint>basda</constraint>
    <constraint>hjk</constraint>
    </param>
    <param access="1" constrainttype="INT_CHOICE" name="list" oid="list" precision="0" type="INT32" value="5" widget="list">
    <constraint key="0">cam1</constraint>
    <constraint key="1">cam2</constraint>
    <constraint key="5">cam3</constraint>
    </param>
    </params>
    </meta>
    <meta/>
    <button buttontype="push" height="40" left="420" name="3 Letters" top="380" width="100">
    <task tasktype="ogscript">var choices = new Array();
    choices[0] = 'One';
    choices[1] = 'Two';
    choices[2] = 'three';


    var newCon = params.createStringChoiceConstraint(choices);
    params.replaceConstraint("toggle", newCon);</task>
    </button>
    <param expand="true" height="400" left="1420" oid="list" top="320" width="260"/>
    <button buttontype="push" height="40" left="520" name="3 Numbers" top="380" width="100">
    <task tasktype="ogscript">var choices = new Array();
    choices[0] = '12';
    choices[1] = '13';
    choices[2] = '14';


    var newCon = params.createStringChoiceConstraint(choices);
    params.replaceConstraint("toggle", newCon);</task>
    </button>
    <label height="40" left="40" name="While changing the same amounth of values, no problem" style="txt-align:west;" top="380" width="340"/>
    <label height="40" left="40" name="What happenes now? changing the amounth of values to 4" style="txt-align:west;" top="440" width="360"/>
    <button buttontype="push" height="40" left="420" name="4 Letters" top="440" width="100">
    <task tasktype="ogscript">var choices = new Array();
    choices[0] = 'One';
    choices[1] = 'Two';
    choices[2] = 'three';
    choices[3] = 'four';

    var newCon = params.createStringChoiceConstraint(choices);
    params.replaceConstraint("toggle", newCon);</task>
    </button>
    <button buttontype="push" height="40" left="520" name="4 Numbers" top="440" width="100">
    <task tasktype="ogscript">var choices = new Array();
    choices[0] = '12';
    choices[1] = '13';
    choices[2] = '14';
    choices[3] = '15';

    var newCon = params.createStringChoiceConstraint(choices);
    params.replaceConstraint("toggle", newCon);</task>
    </button>
    <label height="60" left="240" name="Simple string choice constrint" style="txt-align:center" top="60" width="600"/>
    <simplegrid height="160" left="300" rows="1" top="140" width="520">
    <param expand="true" height="140" left="240" oid="toggle" style="style:toggleButton;" top="140" width="600"/>
    </simplegrid>
    </abs>

     

    Cheers

    James


    #DashBoard


  • 3.  RE: Change toggle buttons amount with replaceConstraint - its a bug?

    Posted 05-25-2020 22:02

    Good to know!
    That's clear now.
    Thanks.


    #DashBoard