Facility Control

 View Only
  • 1.  Basketball Stats Panel - Need help populating dropdowns

    Posted 06-14-2018 19:11

    I need some help with this extensive panel. I’m specifically stuck on implementing stats for basketball. I need help getting my “Stats” tab’s “Setup Stats” button to populate the “Basketball” tab’s “Stats_PlayerName” and “Stats_PlayerNumbers” dropdowns, respectively. These two dropdowns on the “Basketball” tab also needs to be linked to one another. I have tried to replicate what I’ve seen in the tutorials about Populate Dropdowns, and my debug message indicates that my “StatsNames” and “StatsNumbers” array variables are creating entries. I’m pretty sure my problem is with these two lines of code:
    var Stats_PlayerName = params.createIntChoiceConstraint(StatNames);
    var Stats_PlayerNumber = params.createIntChoiceConstraint(StatNumbers);
    I was hoping these lines of code would fill in the dropdowns on the “Basketball” tab, but apparently it does not. I’m fairly new to JavaScript and Dashboard, so I’m stuck. Please help, and feel free to use anything you like here, but this is a work in progress and I have not extensively checked the accuracy all of these calculations just yet. We only ask that you contribute your progress to the community in return, so we all keep getting better. Thanks.
    Link to grid:
    https://drive.google.com/file/d/1-ttlh7tMAcfqQwhcIXXLDJsbE3b9h-99/view?usp=sharing



  • 2.  RE: Basketball Stats Panel - Need help populating dropdowns

    Posted 06-18-2018 15:13
    It's probably easier for me to ask this: "‹I'm trying to make a Drop-Down Menu, BUT I want the items in the menu to come from data entered into multiple Text boxes. Can anybody help? Thanks.
    #DashBoard


  • 3.  RE: Basketball Stats Panel - Need help populating dropdowns

    Posted 06-18-2018 22:30

    I get an error when I try to use your code to see your panel...
    (That is a hell of alot of code btw...)

    What you can do is make a function, on change on any of your text boxes run the function.
    That function must get the value from all the boxes, push those into an array.
    Then you create a second array, and iterate through the first array, add the index and the value into that and update the choice constraint.
    Example panel below with only 4 text boxes:

    <abs contexttype="opengear" gridsize="20" id="_top" style="">
       <meta>
          <api immediate="true">function updateDropdown () {
       var arr = [''];
       arr.push(params.getValue(0x2, 0));
       arr.push(params.getValue(0x3, 0));
       arr.push(params.getValue(0x4, 0));
       arr.push(params.getValue(0x5, 0));
    
       //arr.sort(); &lt;--- Include this one if you want your dropdown sorted alphabetically...
       var cArray = [];
       for (var i = 0; i &lt; arr.length; i++) {
          cArray.push({key:i,value:arr[i]});
       }
       var choiceConstraints = params.createIntChoiceConstraint(cArray);
       params.replaceConstraint(0x6,choiceConstraints);
    }
    
    updateDropdown();</api>
          <params>
             <param access="1" maxlength="0" name="Text 1" oid="0x2" type="STRING" value="Name 1" widget="default"/>
             <param access="1" maxlength="0" name="Text 2" oid="0x3" type="STRING" value="Name 2" widget="default"/>
             <param access="1" maxlength="0" name="Text 3" oid="0x4" type="STRING" value="Name 3" widget="default"/>
             <param access="1" maxlength="0" name="Text 4" oid="0x5" type="STRING" value="Name 4" widget="default"/>
             <param access="1" constrainttype="INT_CHOICE" name="Dropdown" oid="0x6" precision="0" type="INT16" value="3" widget="combo">
                <constraint key="0"/>
                <constraint key="1">Name 1</constraint>
                <constraint key="2">Name 2</constraint>
                <constraint key="3">Name 3</constraint>
                <constraint key="4">Name 4</constraint>
             </param>
             <param access="1" maxlength="0" name="Selected Text" oid="0x7" type="STRING" value="Name 3" widget="default"/>
          </params>
       </meta>
       <param expand="true" height="40" left="20" oid="0x2" top="20" widget="text" width="220">
          <task tasktype="ogscript">updateDropdown();</task>
       </param>
       <param expand="true" height="40" left="20" oid="0x3" top="80" width="220">
          <task tasktype="ogscript">updateDropdown();</task>
       </param>
       <param expand="true" height="40" left="20" oid="0x4" top="140" width="220">
          <task tasktype="ogscript">updateDropdown();</task>
       </param>
       <param expand="true" height="40" left="20" oid="0x5" top="200" width="220">
          <task tasktype="ogscript">updateDropdown();</task>
       </param>
       <param expand="true" height="40" left="20" oid="0x6" showlabel="false" top="260" width="220">
          <task tasktype="ogscript">params.setValue(0x7, 0, params.getValueAsString(0x6, 0));</task>
       </param>
       <label height="40" left="240" name="Selected text: " style="txt-align:east;" top="260" width="100"/>
       <param expand="true" height="40" left="340" oid="0x7" top="260" widget="1" width="280"/>
    </abs>

    Hope this helps! :D


    #DashBoard


  • 4.  RE: Basketball Stats Panel - Need help populating dropdowns

    Posted 06-19-2018 21:15
    In your "Setup Stats" button, I see you creating 2 new constraints but you aren't actually telling any parameter to use them.

    Once the constraint is created, you'd want to use params.replaceConstraint('OID_OF_PARAM', NEW_CONSTRAINT_OBJECT);
    #DashBoard