范例:
以常见的省市县三级联动举例,如下代码是在省下拉框的onChange事件中配置的以常见的省市县三级联动举例,如下代码配置在在省下拉框的onChange事件中的JsAction中
Code Block | ||
---|---|---|
| ||
letvar currentValue = payload.changedValue; //获取当前下拉框的值 if ( !currentValue) { return; } letvar body = {}; //定义请求restAPI的body letvar parentKeys = []; body.entityName = "com.open_care.sys.OcAddress"; body.fieldName = "city"; body.relationFieldName = "parentKey"; parentKeys.push(currentValue); body.parentKeys = parentKeys; function getResponseHandler(response) { letvar targetComponent = ocWindow.getComponentByName('Form1_city'); //根据componentName=Form1_city找到市组件 letvar value = response.data; //获得返回的数据 targetComponent.setOptions(value); //将返回的结果放入市下拉框中 targetComponent.setValueOfFirstOption(); //默认显示下拉框的第一个值 return; } OC.restPostApiCall('/getValueOptions', {}, body, getResponseHandler) //调用后端RestAPI,getResponseHandler为回调函数 |
表格中某一列变为超链接,在Table的onCreate事件中配置JS Action
ocWindow.getComponentByName('Table1').addColumnForHyperLink('vendor_code'); // vendor_code 指Column的DataIndex