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

Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X

Delete Infotable row based on selected row values

Aleksandar
10-Marble

Delete Infotable row based on selected row values

var size = me.Intruders.getRowCount();
var i=0;
for (i=0;i<size;i++)
{
if (me.Intruders.rows.Age == Intruders.Age){
DeleteItem(i);
break;
}

}
function DeleteItem(i)
{ if(i!=0){
me.Intruders.RemoveRow(i);
}
}

 

This is not working , can someone help?

Intruders.Age is a selected row infotable (input parameter) and I am looking to delete a row from Intruders infotable with the Age from selected row.

ACCEPTED SOLUTION

Accepted Solutions

var size = me.Intruders.getRowCount();
var i;
for (i=0;i<size;i++)
{
if (me.Intruders.rows[i].Age == Intruders.Age){
result = "nice";
var myTempTable = me.Intruders;
myTempTable.RemoveRow(i);
me.Intruders = myTempTable;
break;
}

}

 

Thank you for the help, here is the working code if someone needs it.

It deletes the date based on row parameter.

View solution in original post

5 REPLIES 5
PaiChung
22-Sapphire I
(To:Aleksandar)

When you say this is not working, are you getting errors?

Is the infotable persisted or not?

you are doing a direct in memory operation which would mean that is the infotable is persisted, it will retain the original content after a thing restart or system restart.

 

There are no errors, Yes the infotable is presisted.

The Service does not delete a row because the infotable is persisted ?

After the executions, the specific row is still there. It doesn't delete it.

PaiChung
22-Sapphire I
(To:Aleksandar)

To make a persistent delete in an InfoTable property you have to completely re-write the property

so 

myTempTable = me.Intruders

myTempTable.RemoveRow(i)

me.Intruders = myTempTable

Try accessing the value of the property directly. Use +me.Intruders.rows.Age in your if condition statement.

Like : if (+me.Intruders.rows.Age == Intruders.Age). 

var size = me.Intruders.getRowCount();
var i;
for (i=0;i<size;i++)
{
if (me.Intruders.rows[i].Age == Intruders.Age){
result = "nice";
var myTempTable = me.Intruders;
myTempTable.RemoveRow(i);
me.Intruders = myTempTable;
break;
}

}

 

Thank you for the help, here is the working code if someone needs it.

It deletes the date based on row parameter.

Announcements


Top Tags