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 PTC Community Badges. Engage with PTC and see how many you can earn! X

How to update a row in an infoTable?

mbereket
3-Visitor

How to update a row in an infoTable?

Hi Everyone,

So I would like to update a row in an InfoTable, but I couldn't find a snippet for it.

Basically, I would like to find my row first and then update an attribute of it and then push it back to InfoTable

like following:

var foundedRow = me.MyInfoTable.Find(myObject);

foundedRow.color = "blue";

me.MyInfoTable.UpdateRow(myObject,foundedRow)

7 REPLIES 7
wposner-2
12-Amethyst
(To:mbereket)

MyInfoTable.myColumn=myNewValue;

Hi Mustafa,

To update an Infotable Property, you should never do it directly on the property, instead you should copy the Infotable Change it and set it again as a whole on the property ( see step 1 and 4 ):

1. var modified = me.MyInfoTable; // -- This creates a copy of the infotable not a reference

2. var row = modified.Find(myObject);

3. row.color = "Blue";

4. me.MyInfoTable = modified;

Can you explain why you should not modify the property directly?  There is no real difference in copying the infotable except for the fact that you now have another (potentially large) object occupying memory.

Hi Wayne,

That's the recommended way by R&D. Some reasons:

  • You can end you having big concurrency problems otherwise
  • Infotable Property Data Change event won't be thrown if you edit directly the inner row
  • Also, of that I'm not 100% sure, updates done at row level without "notifying the Property" won't be persisted after a Tomcat restart!

Best Regards,

Carles.

Thanks Carles

But I am not sure if you actually forgot to add this 5th step, or we didnt need that

1. var modified = me.MyInfoTable; // -- This creates a copy of the infotable not a reference

2. var row = modified.Find(myObject);

3. row.color = "Blue";

4*. modified.addRow(row);

5. me.MyInfoTable = modified;

You don't need 4* step to modify the row value.

Okay cool, thanks Carles! This was helpful.

Top Tags