Unable to add custom view under List View


As shown in above image as there are multiple views like Report, kanban etc. I wanted to add my own view with specific route. But I’m unable to do so. Do you have any solution for the same. Please help!!!
Thanks in advance !!!

You have to add the custom button in listview and add the condition your according.

Reference:

syntax:

frappe.listview_settings["Your DocType"] = {
    refresh: function(listview) {
    	listview.page.add_menu_item(__("Menu"));
    	listview.page.add_action_item(__("Actions"));
    	listview.page.set_primary_action('Primary Button');
      	listview.page.set_secondary_action('Secondary Button');
    	listview.page.add_inner_button("Inner Button");
    }
};
1 Like

frappe.provide(“frappe.views”);

frappe.views.ListViewSelect = class extends frappe.views.ListViewSelect {
setup_views() {
super.setup_views();
const custom_views = {
Task: {
condition: true,
action: () => this.set_route(“/epp/test”),
}
};
Object.keys(custom_views).forEach(view => {
if (this.current_view !== view && custom_views[view].condition) {
this.add_view_to_menu(view, custom_views[view].action, custom_views[view].icon);
}
});
}

add_view_to_menu(view, action) {
    if (this.doctype == "File" && view == "List") {
        view = "File";
    }
    let $el = this.page.add_custom_menu_item(
        this.parent,
        __(view),
        action,
        true,
        null,
        this.icon_map[view] || "list"
    );
    $el.parent().attr("data-view", view);
}

};

This worked for me.