How to Add a Row to Child Table and populate it with data?

Hello,

I am using this code let new_row_added = frm.get_field("zone_1_batches").grid.add_new_row(); to add a new row to the Child Table. But as the new_row() function is returning nothing I am not able to access the added row to populate it.

How to Add a Row to Child Table and populate it with data?

TIA

Yogi Yang

@YogiYang If the add_new_row returns undefined, then you can access the data through:

let data = frm.get_field("zone_1_batches").grid.df.data;
let row = data[data.length - 1];
row.name = "Name";

But first try the following and see if it returns a row:

let new_row_added = frm.get_field("zone_1_batches").grid.add_new_row(null, null, true, null, true);
2 Likes

Form Scripts - add_child (frappeframework.com)

2 Likes

Hello @kid1194 and @tdci

Solutions provided by both of you are working for me!!

Thanks to both of you.

TIA

Yogi Yang