1 Reply Latest reply on Mar 6, 2017 5:19 AM by Ankit Gupta RSS
    fmanniti Creator

    Can I "append" two infotables without loop?

    If I have two infotables from the same datashape and I want to make a third one given by the two, is it possible to append them in some "smart way" without doing this:

     

    var tableLength = table1.rows.length;
    for (var x = 0; x < tableLength; x++){
        var row = table1.rows[x];
        table3.AddRow(row);
    }
    
    var tableLength = table2.rows.length;
    for (var x = 0; x < tableLength; x++){
        var row = table2.rows[x];
        table3.AddRow(row);
    }
    
    result = table3;
    

     

    ?

    Thanks

      • Re: Can I "append" two infotables without loop?
        Ankit Gupta Ninja

        Hi Fabio Manniti,

         

        I would do it like following:

        1. Get the Row Length of both Infotable.

        2. Copy the one with more length in table 3 by just assigning it. Will not loop in.

        example: Table1 has 1000 Rows and Table2 10000 rows. So I would just do Table3=Table1.

        3. Then loop through the other table and copy each item.

         

        And ThingWorx provide Union option to combine two Infotables into one. I suppose you are looking for this.

         

        var params = {
          t1: undefined /* INFOTABLE */,
          t2: undefined /* INFOTABLE */
        };
        
        // result: INFOTABLE
        var result = Resources["InfoTableFunctions"].Union(params);