How to create button in doctype list view

Hi,

How would i create button before menu

thanks in advance:pray::pray::pray:

hello,
this link should help you i guess
https://frappe.io/docs/user/en/guides/app-development/adding-custom-button-to-form#targetText=To%20create%20a%20custom%20button,a%20button%20to%20your%20form

Hey,

Thanks for response, But i donโ€™t want i want out side or purchase order when purchase order list will show that from that time should show the button like (New, Refresh,Menu)โ€ฆ

1 Like

did you find a way to do that?
need to do it in my app

@justmejust
create a file with name โ€œ[doctype_name]_list.jsโ€ in your doctype folder and then you can adapt this code to get the desired behaviour

frappe.listview_settings["[doctype_name]"] = {

	onload: function(listview) {
		this.add_button([button_name], "default", function() { /*actions*/ })
	},

	add_button(name, type, action, wrapper_class=".page-actions") {
		const button = document.createElement("button");
		button.classList.add("btn", "btn-" + type, "btn-sm", "ml-2");
		button.innerHTML = name;
		button.onclick = action;
		document.querySelector(wrapper_class).prepend(button);
	},
};
1 Like

Thank you @Mohammad_Hasnain
will give it try

1 Like

Its not working.

frappe.listview_settings['MyDocType'] = {
    onload(listview) {
        listview.page.add_button(__('Say hello), function () {
            frappe.msgprint('hello');
        }, {});
    },
}
2 Likes