the solution here is totally correct
https://docs.erpnext.com/docs/user/manual/en/filter-options-in-select-field
frappe.ui.form.on("Lead", "state", function(frm) {
if(frm.doc.state == "Karnataka")
{
set_field_options("city", ["Bangalore","Mysore"])
}
else if(frm.doc.state == "Maharashtra")
{
set_field_options("city", ["Mumbai","Pune"])
}
else if(frm.doc.state == "")
{
set_field_options("city", ["","Bangalore","Mysore","Mumbai","Pune"])
}
});
but when i want this in the list view of related Doctype its not working!
i tried this
created mydoctype_list.js and added the following script:
frappe.listview_settings['mydoctype] = {
onload: function(listview) {
// Add an event listener to the State filter field
listview.page.add_inner_button(__("Refresh"), function() {
var stateFilterValue = frappe.query_report_filters_by_name['state'].get_value();
var districtFilterField = frappe.query_report_filters_by_name['district'];
// Set the options based on the selected gov value
if (stateFilterValue === 'a') {
districtFilterField.df.options = ['1','2','3','4','5'];
} else if (govFilterValue === 'b') {
districtFilterField.df.options =['6','7','8','9','10'];
} else {
districtFilterField.df.options = [];
}
// Refresh the filter field
districtFilterField.refresh();
});
}
};
only refresh button appeared but the district values did not appeared !!!
any help please?