Filter Options in Select Field

Filter Options in Select Field

假设有两个下拉字段State和City。邦有两个值卡纳塔克邦和马哈拉施特拉邦,城市有四个值,班加罗尔,迈索尔,孟买和浦那。如果希望根据State中选择的值过滤City中的选项,可以编写如下所示的自定义脚本。

复制代码
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"])`
  `}`
  `});`
`
相关推荐
爱写程序的白羊4 个月前
使用Frappe-Bench安装其他模块【四】
erpnext·frappe
深圳老张10 个月前
ERPNext vscode Debug
frappe