Show the attachment button when a user clicks on a row in the child table

I manage to show the Attach button when the Add Row button is clicked with this code.

frappe.ui.form.on("Attachment", {
    attachments_add: (frm, cdt, cdn) => {
        let attachment = locals[cdt][cdn];
        $('div[data-idx="'+attachment.idx+'"].grid-row div[data-fieldname="attachment"]').click();
    }
});