HOW TO: set a custom class on listview custom buttons

Listview button formatting

frappe.listview_settings['ASYCUDA Verification'] = {
    refresh: function(listview) {
        download_imports(listview);

        listview.page.add_inner_button(__("Download Imports"), function() {
            download_imports(listview);
             
        });

        // Add the btn-primary class to the button
        listview.page.inner_toolbar.find('button:contains("Download Imports")')
           .removeClass('btn-default')
           .addClass('btn-primary');
    },
};

Bonus

The following styling is for forms but can easily be adapted for the list view

Styling button groups:

frm.page.get_inner_group_button("Imports Menu")
   .find("button")
   .removeClass("btn-default")
   .addClass("btn-success");

Set button group as primary:

frm.page.set_inner_btn_group_as_primary("Imports Menu")
1 Like