Programmatically delete rows of subtable fails on some rows

Hi all,

I have a subtable within a doctype which is used to display some information. Programmatically, this will be purged and then filled again. If there are only few rows, this works nicely, but in case of > 5 rows, one or two rows do not get deleted and therefore remain.

The deletion code block (JavaScript) looks like this:

 // remove all rows
 cur_frm.get_field('composition_results').grid.grid_rows.forEach(function(row) {
    row.remove();
 });

I am running this on ERPNext/Frappe v10.1.

Any ideas how we could really delete all rows?

Seems like this can be resolved/worked around with this code block: How to delete a particular row from a child table? - #8 by sorin.negulescu

var tbl = frm.doc.child_table || [];
var i = tbl.length;
while (i--)
{
    if(tbl[i].field_name == '')
    {
        cur_frm.get_field("child_table").grid.grid_rows[i].remove();
    }
}
cur_frm.refresh();

I like the initial code block better, but it is just not stable enough… :frowning:

it’s not working if i have amount if deleted rows , i have more than 800 row, its not working