Facility Control

 View Only
  • 1.  Struct Table configs

    Posted 10-24-2024 11:58

    Is it possible to dynamically change struct table configs?

    I would like to change "w.columns" with javascript in this example:

    <param bottom="0" expand="true" left="0" oid="roster5" right="0" showlabel="false" top="0">
       <config key="w.columns">firstName, lastName, displayName, jersey, height, hometown, class, major, active</config>
    </param>



    ------------------------------
    David Levy
    Lead Real Time Graphics Developer
    ESPN
    ------------------------------


  • 2.  RE: Struct Table configs

    Posted 10-24-2024 12:36

    Hi David,

    There is no easy native method to affect the configs on a param view however you can easily accomplish this with a setXML method. I've included an example of this below. If that does not suffice the next direction I would take you would be a script table but I feel that would be more trouble than its worth in this case.

    <abs contexttype="opengear" id="_top" keepalive="false" style="">
       <meta>
          <params>
             <param access="1" constrainttype="STRUCT" name="roster.template" oid="roster.template" type="STRUCT" widget="table">
                <value>
                   <subparam access="1" maxlength="0" name="firstName" suboid="firstName" type="STRING" value="" widget="default"/>
                   <subparam access="1" maxlength="0" name="lastName" suboid="lastName" type="STRING" value="" widget="default"/>
                   <subparam access="1" maxlength="0" name="displayName" suboid="displayName" type="STRING" value="" widget="default"/>
                   <subparam access="1" maxlength="0" name="jersey" suboid="jersey" type="STRING" value="" widget="default"/>
                   <subparam access="1" maxlength="0" name="height" suboid="height" type="STRING" value="" widget="default"/>
                   <subparam access="1" maxlength="0" name="hometown" suboid="hometown" type="STRING" value="" widget="default"/>
                   <subparam access="1" maxlength="0" name="class" suboid="class" type="STRING" value="" widget="default"/>
                   <subparam access="1" maxlength="0" name="major" suboid="major" type="STRING" value="" widget="default"/>
                   <subparam access="1" maxlength="0" name="active" suboid="active" type="STRING" value="" widget="default"/>
                </value>
             </param>
             <param access="1" constrainttype="STRUCT" name="roster5" oid="roster5" templateoid="roster.template" type="STRUCT_ARRAY" widget="table">
                <value>
                   <subparam suboid="firstName" value="John"/>
                   <subparam suboid="lastName" value="Smith"/>
                   <subparam suboid="displayName" value="John Smith"/>
                   <subparam suboid="jersey" value="1"/>
                   <subparam suboid="height" value="6'2"/>
                   <subparam suboid="hometown" value="Toronto, ON"/>
                   <subparam suboid="class" value="Senior"/>
                   <subparam suboid="major" value="Computer Science"/>
                   <subparam suboid="active" value="Yes"/>
                </value>
                <value>
                   <subparam suboid="firstName" value="Carl"/>
                   <subparam suboid="lastName" value="White"/>
                   <subparam suboid="displayName" value="Carl White"/>
                   <subparam suboid="jersey" value="2"/>
                   <subparam suboid="height" value="5'10"/>
                   <subparam suboid="hometown" value="Ottawa, ON"/>
                   <subparam suboid="class" value="Junior"/>
                   <subparam suboid="major" value="Biology"/>
                   <subparam suboid="active" value="Yes"/>
                </value>
             </param>
          </params>
       </meta>
       <simplegrid height="260" id="roster5-container" left="60" top="83" width="800">
          <param expand="true" oid="roster5" showlabel="false">
             <config key="w.columns">firstName, lastName, displayName, jersey, height, hometown, class, major, active</config>
          </param>
       </simplegrid>
       <button buttontype="push" height="41" left="61" name="Set Original Cols" top="39" width="205">
          <task tasktype="ogscript">var cols = ["firstName", "lastName", "displayName", "jersey"," height", "hometown", "class", "major", "active"];
    var colsString = cols.join(", ");
    var oglml = '&lt;param expand="true" oid="roster5" showlabel="false"&gt;\n\
       &lt;config key="w.columns"&gt;' + colsString + '&lt;/config&gt;\n\
    &lt;/param&gt;';
    
    ogscript.setXML('roster5-container', oglml);</task>
       </button>
       <button buttontype="push" height="41" left="268" name="Set New Cols" top="39" width="205">
          <task tasktype="ogscript">var cols = ["firstName", "lastName", "jersey"," height", "active"];
    var colsString = cols.join(", ");
    var oglml = '&lt;param expand="true" oid="roster5" showlabel="false"&gt;\n\
       &lt;config key="w.columns"&gt;' + colsString + '&lt;/config&gt;\n\
    &lt;/param&gt;';
    
    ogscript.setXML('roster5-container', oglml);</task>
       </button>
    </abs>
    



    ------------------------------
    Antony Giraldo
    Ross Video
    ------------------------------



  • 3.  RE: Struct Table configs

    Posted 10-24-2024 15:33

    Thanks this is great!

    Is there a way to sort the data on one of the columns with javascript? 

    I'd rather not re-write data in the param. 

    I just want to change how the data is displayed. 

    If I can do it without making the user click that would be great,



    ------------------------------
    David Levy
    Lead Real Time Graphics Developer
    ESPN
    ------------------------------



  • 4.  RE: Struct Table configs

    Posted 10-25-2024 10:11

    Hey David,

    There's a simpler way to do this without javascript if your okay with just clicking the column header you want to use to sort. The trick is the w.sortable config option. This option allows you to click on the header for each column and it will first sort the table rows based on that columns data and the the second time clicked it will reverse sort the table. However any method for sorting will impact the actual saved data order so I think I good way to counteract this would be to add a Row Id column that enumerates based on the true order of the Struct Array. That way if you click on the Row Id column you can use that to get your rows back to the correct order easily.

    Below is an example of that.

    <abs contexttype="opengear" id="_top" keepalive="false" style="">
       <meta>
          <params>
             <param access="1" constrainttype="STRUCT" name="roster.template" oid="roster.template" type="STRUCT" widget="table">
                <value>
                   <subparam access="1" constrainttype="INT_NULL" name="Row Id" precision="0" suboid="rowid" type="INT16" value="1" widget="label"/>
                   <subparam access="1" maxlength="0" name="firstName" suboid="firstName" type="STRING" value="" widget="default"/>
                   <subparam access="1" maxlength="0" name="lastName" suboid="lastName" type="STRING" value="" widget="default"/>
                   <subparam access="1" maxlength="0" name="displayName" suboid="displayName" type="STRING" value="" widget="default"/>
                   <subparam access="1" maxlength="0" name="jersey" suboid="jersey" type="STRING" value="" widget="default"/>
                   <subparam access="1" maxlength="0" name="height" suboid="height" type="STRING" value="" widget="default"/>
                   <subparam access="1" maxlength="0" name="hometown" suboid="hometown" type="STRING" value="" widget="default"/>
                   <subparam access="1" maxlength="0" name="class" suboid="class" type="STRING" value="" widget="default"/>
                   <subparam access="1" maxlength="0" name="major" suboid="major" type="STRING" value="" widget="default"/>
                   <subparam access="1" maxlength="0" name="active" suboid="active" type="STRING" value="" widget="default"/>
                </value>
             </param>
             <param access="1" constrainttype="STRUCT" name="roster5" oid="roster5" templateoid="roster.template" type="STRUCT_ARRAY" widget="table">
                <value>
                   <subparam suboid="rowid" value="1"/>
                   <subparam suboid="firstName" value="John"/>
                   <subparam suboid="lastName" value="Smith"/>
                   <subparam suboid="displayName" value="John Smith"/>
                   <subparam suboid="jersey" value="1"/>
                   <subparam suboid="height" value="6'2"/>
                   <subparam suboid="hometown" value="Toronto, ON"/>
                   <subparam suboid="class" value="Senior"/>
                   <subparam suboid="major" value="Computer Science"/>
                   <subparam suboid="active" value="Yes"/>
                </value>
                <value>
                   <subparam suboid="rowid" value="2"/>
                   <subparam suboid="firstName" value="Carl"/>
                   <subparam suboid="lastName" value="White"/>
                   <subparam suboid="displayName" value="Carl White"/>
                   <subparam suboid="jersey" value="2"/>
                   <subparam suboid="height" value="5'10"/>
                   <subparam suboid="hometown" value="Ottawa, ON"/>
                   <subparam suboid="class" value="Junior"/>
                   <subparam suboid="major" value="Biology"/>
                   <subparam suboid="active" value="Yes"/>
                </value>
                <value>
                   <subparam suboid="rowid" value="3"/>
                   <subparam suboid="firstName" value="Sean"/>
                   <subparam suboid="lastName" value="Black"/>
                   <subparam suboid="displayName" value="Sean Black"/>
                   <subparam suboid="jersey" value="72"/>
                   <subparam suboid="height" value="5'9"/>
                   <subparam suboid="hometown" value="Ottawa, ON"/>
                   <subparam suboid="class" value="Junior"/>
                   <subparam suboid="major" value="Chemestry"/>
                   <subparam suboid="active" value="Yes"/>
                </value>
                <value>
                   <subparam suboid="rowid" value="4"/>
                   <subparam suboid="firstName" value="Michael"/>
                   <subparam suboid="lastName" value="Johnson"/>
                   <subparam suboid="displayName" value="Michael Johnson"/>
                   <subparam suboid="jersey" value="3"/>
                   <subparam suboid="height" value="6'0"/>
                   <subparam suboid="hometown" value="New York, NY"/>
                   <subparam suboid="class" value="Senior"/>
                   <subparam suboid="major" value="Business"/>
                   <subparam suboid="active" value="Yes"/>
                </value>
                <value>
                   <subparam suboid="rowid" value="5"/>
                   <subparam suboid="firstName" value="David"/>
                   <subparam suboid="lastName" value="Brown"/>
                   <subparam suboid="displayName" value="David Brown"/>
                   <subparam suboid="jersey" value="4"/>
                   <subparam suboid="height" value="6'1"/>
                   <subparam suboid="hometown" value="Los Angeles, CA"/>
                   <subparam suboid="class" value="Junior"/>
                   <subparam suboid="major" value="Psychology"/>
                   <subparam suboid="active" value="Yes"/>
                </value>
                <value>
                   <subparam suboid="rowid" value="6"/>
                   <subparam suboid="firstName" value="Robert"/>
                   <subparam suboid="lastName" value="Davis"/>
                   <subparam suboid="displayName" value="Robert Davis"/>
                   <subparam suboid="jersey" value="5"/>
                   <subparam suboid="height" value="6'3"/>
                   <subparam suboid="hometown" value="Chicago, IL"/>
                   <subparam suboid="class" value="Senior"/>
                   <subparam suboid="major" value="Engineering"/>
                   <subparam suboid="active" value="Yes"/>
                </value>
                <value>
                   <subparam suboid="rowid" value="7"/>
                   <subparam suboid="firstName" value="Daniel"/>
                   <subparam suboid="lastName" value="Wilson"/>
                   <subparam suboid="displayName" value="Daniel Wilson"/>
                   <subparam suboid="jersey" value="6"/>
                   <subparam suboid="height" value="6'2"/>
                   <subparam suboid="hometown" value="Houston, TX"/>
                   <subparam suboid="class" value="Junior"/>
                   <subparam suboid="major" value="Marketing"/>
                   <subparam suboid="active" value="Yes"/>
                </value>
                <value>
                   <subparam suboid="rowid" value="8"/>
                   <subparam suboid="firstName" value="Christopher"/>
                   <subparam suboid="lastName" value="Taylor"/>
                   <subparam suboid="displayName" value="Christopher Taylor"/>
                   <subparam suboid="jersey" value="7"/>
                   <subparam suboid="height" value="6'0"/>
                   <subparam suboid="hometown" value="Miami, FL"/>
                   <subparam suboid="class" value="Senior"/>
                   <subparam suboid="major" value="Finance"/>
                   <subparam suboid="active" value="Yes"/>
                </value>
                <value>
                   <subparam suboid="rowid" value="9"/>
                   <subparam suboid="firstName" value="Matthew"/>
                   <subparam suboid="lastName" value="Anderson"/>
                   <subparam suboid="displayName" value="Matthew Anderson"/>
                   <subparam suboid="jersey" value="8"/>
                   <subparam suboid="height" value="6'1"/>
                   <subparam suboid="hometown" value="Dallas, TX"/>
                   <subparam suboid="class" value="Junior"/>
                   <subparam suboid="major" value="Communications"/>
                   <subparam suboid="active" value="Yes"/>
                </value>
                <value>
                   <subparam suboid="rowid" value="10"/>
                   <subparam suboid="firstName" value="James"/>
                   <subparam suboid="lastName" value="Thomas"/>
                   <subparam suboid="displayName" value="James Thomas"/>
                   <subparam suboid="jersey" value="9"/>
                   <subparam suboid="height" value="6'3"/>
                   <subparam suboid="hometown" value="Phoenix, AZ"/>
                   <subparam suboid="class" value="Senior"/>
                   <subparam suboid="major" value="Political Science"/>
                   <subparam suboid="active" value="Yes"/>
                </value>
                <value>
                   <subparam suboid="rowid" value="11"/>
                   <subparam suboid="firstName" value="Joseph"/>
                   <subparam suboid="lastName" value="Jackson"/>
                   <subparam suboid="displayName" value="Joseph Jackson"/>
                   <subparam suboid="jersey" value="10"/>
                   <subparam suboid="height" value="6'2"/>
                   <subparam suboid="hometown" value="Philadelphia, PA"/>
                   <subparam suboid="class" value="Junior"/>
                   <subparam suboid="major" value="History"/>
                   <subparam suboid="active" value="Yes"/>
                </value>
                <value>
                   <subparam suboid="rowid" value="12"/>
                   <subparam suboid="firstName" value="Andrew"/>
                   <subparam suboid="lastName" value="Lee"/>
                   <subparam suboid="displayName" value="Andrew Lee"/>
                   <subparam suboid="jersey" value="11"/>
                   <subparam suboid="height" value="6'0"/>
                   <subparam suboid="hometown" value="San Francisco, CA"/>
                   <subparam suboid="class" value="Senior"/>
                   <subparam suboid="major" value="Computer Engineering"/>
                   <subparam suboid="active" value="Yes"/>
                </value>
                <value>
                   <subparam suboid="rowid" value="13"/>
                   <subparam suboid="firstName" value="Ryan"/>
                   <subparam suboid="lastName" value="Harris"/>
                   <subparam suboid="displayName" value="Ryan Harris"/>
                   <subparam suboid="jersey" value="12"/>
                   <subparam suboid="height" value="6'1"/>
                   <subparam suboid="hometown" value="Seattle, WA"/>
                   <subparam suboid="class" value="Junior"/>
                   <subparam suboid="major" value="Physics"/>
                   <subparam suboid="active" value="Yes"/>
                </value>
                <value>
                   <subparam suboid="rowid" value="14"/>
                   <subparam suboid="firstName" value="Joshua"/>
                   <subparam suboid="lastName" value="Clark"/>
                   <subparam suboid="displayName" value="Joshua Clark"/>
                   <subparam suboid="jersey" value="13"/>
                   <subparam suboid="height" value="6'3"/>
                   <subparam suboid="hometown" value="Denver, CO"/>
                   <subparam suboid="class" value="Senior"/>
                   <subparam suboid="major" value="Mathematics"/>
                   <subparam suboid="active" value="Yes"/>
                </value>
                <value>
                   <subparam suboid="rowid" value="15"/>
                   <subparam suboid="firstName" value="Jason"/>
                   <subparam suboid="lastName" value="Lewis"/>
                   <subparam suboid="displayName" value="Jason Lewis"/>
                   <subparam suboid="jersey" value="14"/>
                   <subparam suboid="height" value="6'2"/>
                   <subparam suboid="hometown" value="Boston, MA"/>
                   <subparam suboid="class" value="Junior"/>
                   <subparam suboid="major" value="English"/>
                   <subparam suboid="active" value="Yes"/>
                </value>
                <value>
                   <subparam suboid="rowid" value="16"/>
                   <subparam suboid="firstName" value="Kevin"/>
                   <subparam suboid="lastName" value="Walker"/>
                   <subparam suboid="displayName" value="Kevin Walker"/>
                   <subparam suboid="jersey" value="15"/>
                   <subparam suboid="height" value="6'0"/>
                   <subparam suboid="hometown" value="Detroit, MI"/>
                   <subparam suboid="class" value="Senior"/>
                   <subparam suboid="major" value="Sociology"/>
                   <subparam suboid="active" value="Yes"/>
                </value>
                <value>
                   <subparam suboid="rowid" value="17"/>
                   <subparam suboid="firstName" value="Brian"/>
                   <subparam suboid="lastName" value="Hall"/>
                   <subparam suboid="displayName" value="Brian Hall"/>
                   <subparam suboid="jersey" value="16"/>
                   <subparam suboid="height" value="6'1"/>
                   <subparam suboid="hometown" value="Atlanta, GA"/>
                   <subparam suboid="class" value="Junior"/>
                   <subparam suboid="major" value="Economics"/>
                   <subparam suboid="active" value="Yes"/>
                </value>
                <value>
                   <subparam suboid="rowid" value="18"/>
                   <subparam suboid="firstName" value="Eric"/>
                   <subparam suboid="lastName" value="Young"/>
                   <subparam suboid="displayName" value="Eric Young"/>
                   <subparam suboid="jersey" value="17"/>
                   <subparam suboid="height" value="6'3"/>
                   <subparam suboid="hometown" value="San Diego, CA"/>
                   <subparam suboid="class" value="Senior"/>
                   <subparam suboid="major" value="Political Science"/>
                   <subparam suboid="active" value="Yes"/>
                </value>
             </param>
          </params>
       </meta>
       <simplegrid height="260" id="roster5-container" left="60" top="83" width="800">
          <param expand="true" oid="roster5" showlabel="false">
             <config key="w.columns">rowid, firstName, lastName, displayName, jersey, height, hometown, class, major, active</config>
             <config key="w.sortable">true</config>
          </param>
       </simplegrid>
       <button buttontype="push" height="41" left="61" name="Set Original Cols" top="39" width="205">
          <task tasktype="ogscript">var cols = ["rowid", "firstName", "lastName", "displayName", "jersey"," height", "hometown", "class", "major", "active"];
    var colsString = cols.join(", ");
    var oglml = '&lt;param expand="true" oid="roster5" showlabel="false"&gt;\n\
       &lt;config key="w.columns"&gt;' + colsString + '&lt;/config&gt;\n\
       &lt;config key="w.sortable"&gt;true&lt;/config&gt;\n\
    &lt;/param&gt;';
    
    ogscript.setXML('roster5-container', oglml);</task>
       </button>
       <button buttontype="push" height="41" left="268" name="Set New Cols" top="39" width="205">
          <task tasktype="ogscript">var cols = ["rowid", "firstName", "lastName", "jersey"," height", "active"];
    var colsString = cols.join(", ");
    var oglml = '&lt;param expand="true" oid="roster5" showlabel="false"&gt;\n\
       &lt;config key="w.columns"&gt;' + colsString + '&lt;/config&gt;\n\
       &lt;config key="w.sortable"&gt;true&lt;/config&gt;\n\
    &lt;/param&gt;';
    
    ogscript.setXML('roster5-container', oglml);</task>
       </button>
    </abs>
    


    If this is not your desired workflow there are other methods that yes use JavaScript however you would still run into the issue of the order of the rows displayed will impact the order of the rows in your struct.

    Please let me know if you want further assistance with the JavaScript method instead.



    ------------------------------
    Antony Giraldo
    DashBoard Custom Panel Developer
    Ross Video Creative Services | Rocket Surgery Triggering and Control
    ------------------------------



  • 5.  RE: Struct Table configs

    Posted 10-28-2024 11:16

    Just a slight clarification/correction: clicking on the column headers only changes the way the data is displayed.  It does not impact the actual ordering of the data underneath.

    Also, another way to make the columns dynamic would be to switch from struct tables to array tables (where each array parameter provides a single column and the entire table is controlled by a choice constraint enumerating the OIDs of the column parameters).  With this type of table, if you update the choice constraint on the parameter that defines the table, it will impact which columns are displayed.  The downside to this is that your records would need to shift away from using struct arrays to define each row (which is very nice to look at especially if you're exporting the data to Datalinq).  Still, just for completeness, I'll show the example:

    <abs contexttype="opengear" style="">
       <meta>
          <params>
             <param access="1" constrainttype="INT_CHOICE" name="Constriant Toggle" oid="Constriant_Toggle" precision="0" type="INT32" value="1" widget="radio-toggle">
                <constraint key="0">Advanced</constraint>
                <constraint key="1">Basic</constraint>
             </param>
             <param access="1" constrainttype="STRING_CHOICE" name="Table" oid="params.table" precision="0" type="INT32" value="-1" widget="table">
                <constraint>col1</constraint>
                <constraint>col2</constraint>
                <constraint>col3</constraint>
             </param>
             <param access="1" maxlength="0" name="Col 1" oid="col1" precision="0" type="STRING_ARRAY" widget="label">
                <value>a</value>
                <value>b</value>
                <value>c</value>
                <value>d</value>
                <value>e</value>
                <value>f</value>
                <value>g</value>
             </param>
             <param access="1" maxlength="0" name="Col 2" oid="col2" precision="0" type="STRING_ARRAY" widget="label">
                <value>1</value>
                <value>2</value>
                <value>3</value>
                <value>4</value>
                <value>5</value>
                <value>6</value>
                <value>7</value>
             </param>
             <param access="1" maxlength="0" name="Col 3" oid="col3" precision="0" type="STRING_ARRAY" widget="label">
                <value>i</value>
                <value>ii</value>
                <value>iii</value>
                <value>iv</value>
                <value>v</value>
                <value>vi</value>
                <value>vii</value>
             </param>
          </params>
       </meta>
       
       <param expand="true" height="90" left="17" oid="Constriant_Toggle" runtasksonload="true" style="style:toggleButton;" top="303" width="583">
          <task tasktype="ogscript">var cArray = null;
    if (this.getValue() == 0)
    {
       cArray = ['col1', 'col2', 'col3'];
    }
    else
    {
       cArray = ['col1', 'col2'];
    }
    
    var choiceConstraint = params.createStringChoiceConstraint(cArray);
    params.replaceConstraint('params.table', choiceConstraint);</task>
       </param>
    <param expand="true" height="278" left="17" oid="params.table" showlabel="false" top="17" width="580"/>
    </abs>
    


    ------------------------------
    James Peltzer
    Ross Video
    ------------------------------