Page tree

版本比较

标识

  • 该行被添加。
  • 该行被删除。
  • 格式已改变。

...

以常见的省市县三级联动举例,如下代码配置在在省下拉框的onChange事件中的JsAction中

Code Block
languagejs
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为回调函数

...

ocWindow.getComponentByName('Table1').addColumnForHyperLink('vendor_code'); // vendor_code 指Column的DataIndex

Office Word
nameJS SDK使用说明.docx