How to apply filter for listview of doctype using client script

Hello Team,

Im trying to filter list of records using shortlist button when i click on button unable to filter the records but able to filter using in-build filter

frappe.listview_settings[‘Candidate form’] = {
onload: function (list_view) {
let me = this;

  // Add the first button
  list_view.page.add_inner_button(__('Shortlisted'), function () {
    // Set the filter options
    console.log("hi..")
    frappe.route_options = {
        'is_shortlisted': [ '=',  1 ]
    };
    // Refresh the list view with the new filter
    list_view.refresh();
    console.log(list_view)

  });
}

};

Thanks,
Dhanvantari

Hi @Dhanuyeole,

Same scenario we applied for the item without using frappe.route_options because frappe.route_options does not work.

Please apply and try it.

frappe.listview_settings['Item'] = {
	refresh: function(listview) {
	    listview.page.add_inner_button(("Disabled"), () => {
            window.location.href = "/app/item/?disabled=1";
	    });
	}
};

When click on the button then apply the filter.

Output:

Thank You!

1 Like