Facility Control

 View Only
  • 1.  Empty an array parameter?

    Posted 02-02-2018 13:14

    So.. Kinda hoping there is a really simple sollution to this one that I have yet to grasp...
    I am trying to make a table where I want to be able to empty and "reset" the entries when I push a button.

    Since the parameters dont really act like arrays (but still kinda do) in javascript, I am somewhat stuck at how to "empthy" the parameters making up the table.
    In javascript, emptying an array would be as simple as...

    var arr1 = ["a","b","c","d","e"];
    
    arr1 = [];

    This would basically empty out the array names "arr1". However I cant find a way to do this in DashBoard?
    I hope this is just a case of "fridays" and getting ready for the weekend. Anyone?

    I am also looking for how to count the number of rows in the table.



  • 2.  RE: Empty an array parameter?

    Posted 02-02-2018 14:07
    Ok, I did find the "setAllValues" function to basically remove whatever extra I have.
    Now I need to get the x-number of rows in said table.
    #DashBoard


  • 3.  RE: Empty an array parameter?

    Posted 02-02-2018 14:27

    One thing to note - DashBoard parameters should never be "empty". You'll want to make sure you always have at least one value in any parameter.

    We "reset" string arrays with params.setAllValues('OID', ['']);
    We "reset" int arrays with params.setAllValues('OID', [0]);

    If you want to make a new array that keeps the same number of elements but clears all of the values:

    var newValue = [];
    for (var i = 0; i < params.getElementCount('OID'); i++)
    {
        newValue.push('');
    }
    
    params.setAllValues('OID', newValue);

    #DashBoard


  • 4.  RE: Empty an array parameter?

    Posted 02-03-2018 10:13
    Yeah... Returning to the documentation got me what I needed.
    Both the "setAllValues" and the "getElementCount".

    Thanks again though @jamespeltzer !
    #DashBoard