Skip to main content
17-Peridot
August 18, 2021
Solved

infotable

  • August 18, 2021
  • 3 replies
  • 1917 views

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?

Best answer by ShirishMorkhade_238755

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

3 replies

5-Regular Member
August 19, 2021

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.

17-Peridot
August 19, 2021

@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

16-Pearl
August 20, 2021

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

17-Peridot
August 24, 2021

@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