I want to select only four fow in child table after four row not add any row

I want to select only four fow in child table after four row not add any row


frappe.ui.form.on("Child Table Name", {
    field_name_add: (frm, cdt, cdn) => {
        if(Object.keys(locals[cdt]).length == 4){
            $(".grid-add-row").hide();
        } else {
            $(".grid-add-row").show();
        }
    }
})