I want to add button in child table like upload and download.
let btn = document.createElement(“button”)
btn.innerText = “abc”
frm.fields_dict.items.grid.wrapper.find(“.grid-upload”).removeClass(“hide”).parent().append(btn)
items is child table name
you can delete removeClass(“hide”) if download & upload btn alread existed.
I don’t think my code hide anything.
Ok, my code might not understandable. Hope other has a better one.
frappe.ui.form.on("Sales Invoice", {
onload: function (frm, cdt, cdn) {
let btn = document.createElement('a');
btn.innerText = 'Refresh';
btn.className = 'grid-upload btn btn-xs btn-default';
frm.fields_dict.items.grid.wrapper.find('.grid-upload').removeClass('hide').parent().append(btn);
btn.addEventListener("click", function(){
});
}
})
Thanks for hint @magic-overflow . This is what I’m looking for.
There (now at least) is a more elegant solution:
frm.fields_dict["my_table"].grid.add_custom_button(__('My Label'), function() {});
Which event is suitable for this? I use refresh event and sometimes my buttons doubled, tripelled
You can also apply styling to your custom button How to add a custom button on child table - #4 by sanjay
I use the refresh event and haven’t had that problem, so far.
What Frappe Version are you on?
Have you tried onload instead?