O2OA API

Class

Source

Extends

Source 数据源组件。

Usable Range

Portal

Example

//可以在脚本中获取该组件
//方法1:
var source = this.form.get("fieldId"); //获取数据源组件
//方法2
var source = this.target; //在组件本身的脚本中获取

Source

Members

dataArray|Object|String|Number|Boolean|Null

该属性获取当前数据源的数据,当数据源加载完成后才有值。

Type

  • Array | Object | String | Number | Boolean | Null

Example

var field = this.form.get("fieldId").data; //获取数据源数据

Source

jsonJsonObject

组件的配置信息,比如id,类型,是否只读等等。可以在组件的queryLoad事件里修改该配置来对组件做一些改变。

Type

  • JsonObject

Example

//可以在脚本中获取该组件
var json = this.form.get("fieldId").json; //获取组件对象
var id = json.id; //获取组件的id
var type = json.type; //获取组件的类型,如Textfield 为文本输入组件,Select为下拉组件

//在组件queryLoad事件里设置组件只读。
//当前组件的queryLoad事件运行时还没有在form里注册,通过this.form.get("fieldId")不能获取到当前组件,需要用this.target获取。
var json = this.target.json;
json.isReadonly = true; //设置组件为只读。

Source

parentLineMWF.xApplication.process.Xform.Datatemplate.Line|MWF.xApplication.process.Xform.DatatablePC.Line|MWF.xApplication.process.Xform.DatatableMobile.Line

当前组件在数据表格或者数据模板中时,可以通过此属性获取所在行(条目)对象.

Type

  • MWF.xApplication.process.Xform.Datatemplate.Line | MWF.xApplication.process.Xform.DatatablePC.Line | MWF.xApplication.process.Xform.DatatableMobile.Line

Example

//获取当前组件所在数据模板/数据表格的行(条目)对象
var line = this.target.parentLine;
//获取当前字段所在行下标
var index = line.getIndex();
//获取当前字段所在条目的subject字段的值
var data = line.getModule("subject").getData();
//设置当前字段所在条目的subject字段的值
line.getModule("subject").setData("test1");

Source

Methods

setParameters(url参数)

替换全部的url参数,但不刷新组件

Parameters

  • url参数 Object

Example

//如,原来的组件url参数为:
{ "page" : 1, "count" : 10  }

this.form.get("fieldId").setParameters({"id":"662ede34-4e21-428a-9c3b-f1bf14d15650"});

//执行后变为
{"id":"662ede34-4e21-428a-9c3b-f1bf14d15650"}

Source

addParameters(url参数)

新增url参数,但不刷新组件。如果该参数key已经存在,则覆盖

Parameters

  • url参数 Object

Example

* //如,原来的组件url参数为:
{ "page" : 1, "count" : 10  }

this.form.get("fieldId").addParameters({
 "page" : 2,
 "id":"662ede34-4e21-428a-9c3b-f1bf14d15650"
 });

//执行后变为
{
 "page" : 2,
 "count" : 10
 "id":"662ede34-4e21-428a-9c3b-f1bf14d15650"
 }

Source

reload(notInit, callback)

重新加载组件。会触发loadData事件

Parameters

  • notInit Boolean

    false表示不重新初始化子数据源和数据文本,true表示重新初始化,默认为false

  • callback function

    加载完成后的回调

Example

this.form.get("fieldId").reload(); //重新加载组件

Source

getSource(typeopt) → {Source|SubSource|SubSourceItem}

当前组件在数据源组件中时,可以通过此方法获取所在的上级数据源/子数据源/子数项组件.

Parameters

  • type String <optional>

    需要获取的类型,"source"为表示数据源,"subSource"表示子数据源,"subSourceItem"表示子数据项组件。 如果该参数省略,则获取离当前组件最近的上述组件。

Returns

  • Source SubSource SubSourceItem

Example

var source = this.target.getSource(); //获取当前组件的所在子上级数据源/子数据源/子数项组件.
var data = source.data; //获取数据

var source = this.form.get("fieldId").getSource("source"); //获取数据源组件
var data = source.data; //获取数据

Source

getParentModule(typeopt, validateFunctionopt) → {MWF.xApplication.process.Xform.$Module}

获取当前组件所在的祖先组件.

Parameters

  • type String <optional>

    需要获取的组件类型。 如果该参数省略,则获取离当前组件最近的祖先组件。type有效值如下:

    form- 表单
    common- 通用组件
    datatable- 数据表格
    datatableline- 数据表格行
    datatemplate- 数据模板
    datatemplateline- 数据模板行
    div- 容器组件
    elcommon- Element通用组件
    elcontainer- Element容器组件
    subform- 子表单
    source- 数据源组件
    subsource- 子数据源
    subsourceitem- 子数据项组件
    tab- 分页组件
    tabpage- 分页组件的某个分页
    table- 表格
    tabletd- 单元格
    widget- 部件
  • validateFunction function <optional>

    进一步校验,参数为获取到匹配到类型的组件,返回false继续往上取对应类型的组件,返回true返回该组件。

Returns

Example

var module = this.target.getParentModule(); //获取最近的祖先。

var datatemplateLine = this.target.getParentModule("datatemplateline"); //获取当前组件所在的数据模板行.

var module = this.target.getParentModule(null, function(module){
    return module.json.id === "div_1";
}); //获取当前组件id为div_1的父组件。

Source

Events

postLoadData

加载数据后执行,但这时还未加载下属组件,可以可以使用this.target.data获取数据进行修改。

results matching

    No results matching ''