Facility Control

 View Only
  • 1.  Struct Array Table to dropdown

    Posted 10-11-2024 14:58

    Trying to push data from a table to a dropdown box.

    I am able to get the first row to populate but not the rest.

    Any ideas?

    <abs contexttype="opengear" dblinqport="2222" gridsize="20" keepalive="true">
       <meta>
          <lookup id="hosts">
             <entry key="local.port">7788</entry>
             <entry key="local.host">localhost</entry>
          </lookup>
          <params>
             <param access="1" constrainttype="STRUCT" name="Team Info" oid="templates.teamInfo" structtype="com.rossvideo.playinfo" type="STRUCT" widget="table">
                <value>
                   <subparam access="1" maxlength="0" name="Name" suboid="TeamName" type="STRING" value="Test" widget="default"/>
                   <subparam access="1" maxlength="0" name="Number" suboid="TeamNumber" type="STRING" value="Test" widget="default"/>
                   <subparam access="1" maxlength="0" name="Country" suboid="TeamCountry" type="STRING" value="Test" widget="default"/>
                   <subparam access="1" maxlength="0" name="Finish Time" suboid="TeamFinish" type="STRING" value="Test" widget="default"/>
                   <subparam access="1" maxlength="0" name="Split 1" suboid="TeamSplit1" type="STRING" value="Test" widget="default"/>
                   <subparam access="1" maxlength="0" name="Split 2" suboid="TeamSplit2" type="STRING" value="Test" widget="default"/>
                   <subparam access="1" maxlength="0" name="Split 3" suboid="TeamSplit3" type="STRING" value="Test" widget="default"/>
                   <subparam access="1" maxlength="0" name="Split 4" suboid="TeamSplit4" type="STRING" value="Test" widget="default"/>
                </value>
             </param>
             <param access="1" maxlength="0" name="runClock" oid="runClock" type="STRING" value="00:00.000" widget="label"/>
             <param access="1" constrainttype="INT_CHOICE" name="Confirm Prompt" oid="Confirm_Prompt" precision="0" type="INT32" value="1" widget="button-prompt">
                <config key="w.changeprompt">Submit changes?</config>
                <constraint key="0">Submit</constraint>
                <constraint key="1">Submit</constraint>
             </param>
             <param access="1" maxlength="0" name="rowstyles" oid="rowstyles" type="STRING" value="bg#000011;fg#ffffff" widget="default"/>
             <param access="1" constrainttype="STRUCT" name="Team Info" oid="params.teamList" structtype="com.rossvideo.teaminfo" templateoid="templates.teamInfo" type="STRUCT_ARRAY" widget="table">
                <value>
                   <subparam suboid="TeamName" value="Name 1"/>
                   <subparam suboid="TeamNumber" value="1"/>
                   <subparam suboid="TeamCountry" value="GBR"/>
                   <subparam suboid="TeamFinish" value="1:02.124"/>
                   <subparam suboid="TeamSplit1" value="+1:56.125"/>
                   <subparam suboid="TeamSplit2" value=""/>
                   <subparam suboid="TeamSplit3" value=""/>
                   <subparam suboid="TeamSplit4" value=""/>
                </value>
                <value>
                   <subparam suboid="TeamName" value="Name 2"/>
                   <subparam suboid="TeamNumber" value="2"/>
                   <subparam suboid="TeamCountry" value="IRL"/>
                   <subparam suboid="TeamFinish" value="1:07.321"/>
                   <subparam suboid="TeamSplit1" value="72\"/>
                   <subparam suboid="TeamSplit2" value=""/>
                   <subparam suboid="TeamSplit3" value=""/>
                   <subparam suboid="TeamSplit4" value=""/>
                </value>
                <value>
                   <subparam suboid="TeamName" value="Name 3"/>
                   <subparam suboid="TeamNumber" value="3"/>
                   <subparam suboid="TeamCountry" value="GBR"/>
                   <subparam suboid="TeamFinish" value="1:06.256"/>
                   <subparam suboid="TeamSplit1" value=""/>
                   <subparam suboid="TeamSplit2" value=""/>
                   <subparam suboid="TeamSplit3" value=""/>
                   <subparam suboid="TeamSplit4" value=""/>
                </value>
                <value>
                   <subparam suboid="TeamName" value="Name 4"/>
                   <subparam suboid="TeamNumber" value="4"/>
                   <subparam suboid="TeamCountry" value="FRA"/>
                   <subparam suboid="TeamFinish" value="59.231"/>
                   <subparam suboid="TeamSplit1" value=""/>
                   <subparam suboid="TeamSplit2" value=""/>
                   <subparam suboid="TeamSplit3" value=""/>
                   <subparam suboid="TeamSplit4" value=""/>
                </value>
                <value>
                   <subparam suboid="TeamName" value="Name 5"/>
                   <subparam suboid="TeamNumber" value="5"/>
                   <subparam suboid="TeamCountry" value="AUS"/>
                   <subparam suboid="TeamFinish" value=""/>
                   <subparam suboid="TeamSplit1" value=""/>
                   <subparam suboid="TeamSplit2" value=""/>
                   <subparam suboid="TeamSplit3" value=""/>
                   <subparam suboid="TeamSplit4" value=""/>
                </value>
                <value>
                   <subparam suboid="TeamName" value=""/>
                   <subparam suboid="TeamNumber" value=""/>
                   <subparam suboid="TeamCountry" value=""/>
                   <subparam suboid="TeamFinish" value=""/>
                   <subparam suboid="TeamSplit1" value=""/>
                   <subparam suboid="TeamSplit2" value=""/>
                   <subparam suboid="TeamSplit3" value=""/>
                   <subparam suboid="TeamSplit4" value=""/>
                </value>
             </param>
             <param access="1" constrainttype="INT_CHOICE" name="NumberDropdown" oid="NumberDropdown" precision="0" type="INT16" value="0" widget="default">
                <constraint key="0">3</constraint>
             </param>
             <param access="1" constrainttype="INT_CHOICE" name="PlayerDropdown" oid="PlayerDropdown" precision="0" type="INT16" value="0" widget="default">
                <constraint key="0">Name 3</constraint>
             </param>
             <param access="1" constrainttype="INT_CHOICE" name="CountryDropdown" oid="CountryDropdown" precision="0" type="INT16" value="0" widget="default">
                <constraint key="0">GBR</constraint>
             </param>
             <param access="1" constrainttype="INT_CHOICE" name="FinishDropdown" oid="FinishDropdown" precision="0" type="INT16" value="0" widget="default">
                <constraint key="0">1:01.321</constraint>
             </param>
             <param access="1" constraint="0.0;100.0;0.0;100.0;1" constrainttype="INT_STEP_RANGE" name="Selection" oid="Selection" precision="0" type="INT32" value="4" widget="default"/>
             <param access="1" constrainttype="INT_CHOICE" name="Dropdown" oid="params.combo" precision="0" type="INT16" value="0" widget="combo">
                <constraint key="0">a</constraint>
                <constraint key="1">b</constraint>
                <constraint key="2">c</constraint>
                <constraint key="3">d</constraint>
             </param>
             <param access="1" constrainttype="STRING_CHOICE" name="Table" oid="params.table" precision="0" type="INT16" value="0" widget="table">
                <constraint>params.array</constraint>
             </param>
             <param access="1" constrainttype="INT_CHOICE" name="Split1Dropdown" oid="Split1Dropdown" precision="0" type="INT16" value="0" widget="default">
                <constraint key="0">1:01.321</constraint>
             </param>
          </params>
       </meta>
       <table colspan="1" fill="both" height="540" insets="2,2,2,10" left="60" rowspan="1" style="bg#dark;bdr:round;" top="60" weightx="1.0" weighty="1.0" width="1000">
          <tr>
             <label colspan="2" fill="both" insets="2,2,2,2" name="Competitiors" rowspan="1" style="txt-align:west;font:bold;size:Big;" weightx="1.0" weighty="0.0"/>
          </tr>
          <tr>
             <param colspan="7" constrainttype="STRING_CHOICE" element="0" evenstyle="f:bg#tablezebra;" fill="both" insets="2,2,2,2" oid="params.teamList" precision="0" rowspan="1" showlabel="false" style="t:bg#696969;" weightx="1.0" weighty="1.0">
                <config key="w.selectionparam">Selection</config>
                <config key="w.reorder">true</config>
                <config key="w.padding">10,15</config>
                <config key="w.colminwidth.0">250</config>
                <constraint>TeamName</constraint>
                <constraint>TeamNumber</constraint>
                <constraint>TeamFinish</constraint>
                <constraint>TeamCountry</constraint>
                <constraint>TeamSplit1</constraint>
                <constraint>TeamSplit2</constraint>
                <constraint>TeamSplit3</constraint>
                <constraint>TeamSplit4</constraint>
             </param>
          </tr>
       </table>
       <param expand="true" height="60" left="1220" oid="PlayerDropdown" precision="0" showlabel="false" style="size:Biggest;bdr:round;" top="180" widget="combo" width="260">
          <task tasktype="ogscript">// Set the number to match
    var player = params.getValue('PlayerDropdown', 0);
    var number = params.getValue('NumberDropdown',0);
    var country = params.getValue('CountryDropdown',0);
    var finish = params.getValue('FinishDropdown',0);
    
    if (player != number)
       {
       ogscript.debug('Player dropdown value, doing change to:' + player);
       params.setValue('NumberDropdown', 0, player);
       }
    else
       ogscript.debug('Player dropdown value, No Change:' + player);
    
       if (player != country)
       {
       ogscript.debug('Player dropdown value, doing change to:' + player);
          params.setValue('CountryDropdown', 0, player);
       }
    else
       ogscript.debug('Player dropdown value, No Change:' + player);
    
    
    if (finish != country)
       {
       ogscript.debug('Number dropdown value, doing change to:' + player);
          params.setValue('FinishDropdown', 0, number);
       }
    else
       ogscript.debug('Number dropdown value, No change to:' + number);</task>
       </param>
       <param expand="true" height="60" left="1120" oid="NumberDropdown" precision="0" showlabel="false" style="bdr:round;" top="180" widget="combo" width="80">
          <task tasktype="ogscript">// Set the number to match
    var player = params.getValue('PlayerDropdown', 0);
    var number = params.getValue('NumberDropdown',0);
    var country = params.getValue ('CountryDropdown',0);
    var finish = params.getValue ('FinishDropdown',0);
    
    if (player != number)
       {
       ogscript.debug('Number dropdown value, doing change to:' + player);
       params.setValue('PlayerDropdown', 0, number);
       }
    else
       ogscript.debug('Number dropdown value, No change to:' + number);
    
       if (country != number)
       {
       ogscript.debug('Number dropdown value, doing change to:' + player);
          params.setValue('CountryDropdown', 0, number);
       }
    else
       ogscript.debug('Number dropdown value, No change to:' + number);
    
    if (finish != number)
       {
       ogscript.debug('Number dropdown value, doing change to:' + player);
          params.setValue('FinishDropdown', 0, number);
       }
    else
       ogscript.debug('Number dropdown value, No change to:' + number);</task>
       </param>
       <param expand="true" height="40" left="1120" oid="CountryDropdown" style="bg#textbg;" top="260" widget="label" width="120"/>
       <param expand="true" height="40" left="1260" oid="FinishDropdown" style="bg#textbg;" top="260" widget="label" width="140">
          <task tasktype="ogscript"/>
       </param>
       <param colspan="2" expand="true" fill="both" height="60" insets="2,2,2,2" left="1320" oid="Confirm_Prompt" rowspan="1" style="style:toggleButton;bg#001FC1;size:Big;font:bold;txt-align:center;" top="100" width="180">
          <task tasktype="ogscript"/>
          <task tasktype="ogscript">var i;      // loop counter
    
    for (i=0;i&lt;30;i++)  // Hardcoded to 30 elements in the player names
    { 
       Name = params.getValue('params.teamList.TeamName', i);
       Number = params.getValue('params.teamList.TeamNumber',i);
       Country = params.getValue('params.teamList.TeamCountry',i);
       Finish = params.getValue('params.teamList.TeamFinish',i);
       Split1 = params.getValue('params.teamList.TeamSplit1',i);
    }
    
    // Now update the constraint
    
    params.replaceConstraint('PlayerDropdown', constraintName);
    params.replaceConstraint('NumberDropdown', constraintNumber);
    params.replaceConstraint('CountryDropdown', constraintCountry);
    params.replaceConstraint('FinishDropdown', constraintFinish);
    params.replaceConstraint('Split1Dropdown', constraintSplit1);
    
    
    ogscript.debug('Starting to Create Dropdowns');
    //
    
    var Names = new Array();
    var Numbers = new Array();
    var Country = new Array();
    var Finish = new Array();
    var Split1 = new Array();
    
    var i;      // loop counter
    var name;   // Temp name value
    var number; // Temp number value
    var country; // Temp country value
    var finish; // Temp finish value
    var split1; // Temp split1 value
    
    // Names
    
    for (i=0;i&lt;30;i++)  // Hardcoded to 30 elements in the player names
    { 
       name = params.getValue('params.teamList.TeamName', i);
       number = params.getValue('params.teamList.TeamNumber',i);
       country = params.getValue('params.teamList.TeamCountry',i);
       finish = params.getValue('params.teamList.TeamFinish',i);
       split1 = params.getValue('params.teamList.TeamSplit1',i);
       
       ogscript.debug('Found Player: ' + name + ' Jersey: ' + number);
    
       // Skip this one if the value is the default value
       if (name != 'Insert Name')
          {
             ogscript.debug('Adding Entry: ' + name);
             Names[Names.length] = name;
             Numbers[Numbers.length] = number;  
             Country[Country.length] =country;         
             Finish[Finish.length] =finish;
             Split1[Split1.length] =split1;  
          }
    }
    
    // Now update the constraint
    
    params.replaceConstraint('NumberDropdown', params.createIntChoiceConstraint(Numbers));
    params.replaceConstraint('PlayerDropdown', params.createIntChoiceConstraint(Names));
    params.replaceConstraint('CountryDropdown', params.createIntChoiceConstraint(Country));
    params.replaceConstraint('FinishDropdown', params.createIntChoiceConstraint(Finish));
    params.replaceConstraint('Split1Dropdown', params.createIntChoiceConstraint(Split1));
    
    ogscript.debug('Names.length:' + Names.length);</task>
       </param>
       <param colspan="2" expand="true" fill="both" height="60" insets="2,2,2,2" left="1120" oid="Confirm_Prompt" rowspan="1" style="style:toggleButton;bg#001FC1;size:Big;font:bold;txt-align:center;" top="100" width="180">
          <task tasktype="ogscript"/>
          <task tasktype="ogscript">var newValuesName = params.getAllValues('params.teamList.TeamName');
    var constraintName = params.createIntChoiceConstraint(newValuesName);
    
    var newValuesNumber = params.getAllValues('params.teamList.TeamNumber');
    var constraintNumber = params.createIntChoiceConstraint(newValuesNumber);
    
    var newValuesCountry = params.getAllValues('params.teamList.TeamCountry');
    var constraintCountry = params.createIntChoiceConstraint(newValuesCountry);
    
    var newValuesFinish = params.getAllValues('params.teamList.TeamFinish');
    var constraintFinish = params.createIntChoiceConstraint(newValuesFinish);
    
    var newValuesSplit1 = params.getAllValues('params.teamList.TeamSplit1');
    var constraintSplit1 = params.createIntChoiceConstraint(newValuesSplit1);
    
    params.replaceConstraint('PlayerDropdown', constraintName);
    params.replaceConstraint('NumberDropdown', constraintNumber);
    params.replaceConstraint('CountryDropdown', constraintCountry);
    params.replaceConstraint('FinishDropdown', constraintFinish);
    params.replaceConstraint('Split1Dropdown', constraintSplit1);</task>
       </param>
       <param expand="true" height="40" left="1420" oid="Split1Dropdown" style="bg#textbg;" top="260" widget="label" width="140">
          <task tasktype="ogscript"/>
       </param>
    </abs>



    ------------------------------
    Sam McIntosh
    National Rugby League
    Australia
    ------------------------------



  • 2.  RE: Struct Array Table to dropdown

    Posted 10-15-2024 16:01

    Hello,

    I took a brief look... I used this code to populate your number and name dropdowns:

    var number;
    var numberArray = new Array();
    var name;
    var nameArray = new Array();
    var length = params.getElementCount('params.teamList');
    length = length -1;
    
    for (var i=0;i<=length;i++)
    {
       number = params.getValue('params.teamList.' + i +'.TeamNumber', 0);
       name = params.getValue('params.teamList.' + i +'.TeamName', 0);
    
       if (number != "")
          {
             ogscript.debug('Adding Dropdown Number: ' + number);
             ogscript.debug('Adding Dropdown Name: ' + name);
             numberArray[numberArray.length] = number; 
             nameArray[nameArray.length] = name;    
          }
    }
    
    params.replaceConstraint('NumberDropdown', params.createIntChoiceConstraint(numberArray));
    params.replaceConstraint('PlayerDropdown', params.createIntChoiceConstraint(nameArray));

    However.... what I did find is that even with this code, if I had it on the prompt button, it would only populate the first row as you said. When I put the code on just a normal button it seems to work fine. Why the prompt button seems to only limit it to doing one row, I don't know!



    ------------------------------
    Jake Lew
    Access Communications Co-Operative Limited
    Regina Canada
    ------------------------------



  • 3.  RE: Struct Array Table to dropdown

    Posted 10-17-2024 07:58

    Thanks Jake, thats great!

    It seems to work fine on my prompt buttons so maybe just a bug



    ------------------------------
    Sam McIntosh
    National Rugby League
    Australia
    ------------------------------