deleteRow fails
Hello,
I got an for loop. With this loop i want to remove rows from my table. But when I start removing it looks like that the indexes are changing of my table. I got a rowCount of 9, when i removed more than 4 rows i goes wrong.
Am i right? And how to solve this problem?
My for loop:
var rows = window.table.data[0].rowCount;
window.table.remove();
for(var i = 0; i < rows; i++)
{
try {
window.table.deleteRow(i);
} catch(e) {
Ti.API.error(e);
}
}
Thanks,
Jacob
2 Answers
-
Found a simple solution myself:
var table = window.table; var rows = table.data[0].rowCount; while(rows) { window.table.deleteRow(0); //Always delete the first key rows = table.data[0].rowCount; }
-
If you want to delete all the rows you can just set the data to nothing:
window.table.setData(null);