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

infotable

AP_9587236
17-Peridot

infotable

Why this code is not removing all the rows in infotable? If i have 100 rows, it is removing only 50 rows.

code:

for(var a=0;a<updaterows.rows.length;a++){
var newEntry1 = updaterows;
newEntry1.RemoveRow(a);
updaterows=newEntry1;
}
Anyone knows the code to remove/delete all the rows in infotable?

ACCEPTED SOLUTION

Accepted Solutions

Hi @AP_9587236 ,

No need iterate through for loop. You can simply use RemoveAllRows() of the Info table. I am using it at multiple location in my code and it works like charm. 

var tmpInfoTable = <get your info table>;
tmpInfoTable.RemoveAllRows();

 

Hope it helps you.

 

- Shirish

View solution in original post

4 REPLIES 4

Because when you remove row[0], the old row[1] will be new row[0], and your variable a=1 actually removed the old row[2] ?   

You may check if all the even number rows got deleted and single level rows retained.

@AP_9587236

 

Your code is ok but you need to do the operations backwards.

 

maxIndex = updaterows.rows.length -1;

for(var a=maxIndex;a>=0;a--){
   updaterows.RemoveRow(a);
}

 

By going through the list backwards you avoid the shifting rows.

When you use the updaterows.rows.length in the for loop each time through the loop its value is recalculated.

 

Hope that helps

Peter

Hi @AP_9587236 ,

No need iterate through for loop. You can simply use RemoveAllRows() of the Info table. I am using it at multiple location in my code and it works like charm. 

var tmpInfoTable = <get your info table>;
tmpInfoTable.RemoveAllRows();

 

Hope it helps you.

 

- Shirish

@AP_9587236,

 

ShirishMorkhade is correct. If the goal is to remove all the table entries <infotable>.RemoveAllRows(); will accomplish it in one move.

 

If we are missing the question you are trying to ask please provide more detail.

 

Thanks

Peter

Announcements


Top Tags