cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

Can I "append" two infotables without loop?

fmanniti
9-Granite

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;

    table3.AddRow(row);

}

var tableLength = table2.rows.length;

for (var x = 0; x < tableLength; x++){

    var row = table2.rows;

    table3.AddRow(row);

}

result = table3;

?

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
ankigupta
5-Regular Member
(To:fmanniti)

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);

View solution in original post

1 REPLY 1
ankigupta
5-Regular Member
(To:fmanniti)

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);

Top Tags