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

Community Tip - Help us improve the PTC Community by taking this short Community Survey! X

How to update a row in an infoTable?

mbereket
3-Newcomer

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
14-Alexandrite
(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;

wposner-2
14-Alexandrite
(To:CarlesColl)

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.

Announcements


Top Tags