usable range
process
cms
portal
example
//可以在脚本中获取该组件
//方法1:
var field = this.form.get("fieldid"); //获取组件对象
//方法2
var field = this.target; //在组件本身的脚本中获取,比如事件脚本、默认值脚本、校验脚本等等
var data = field.getdata(); //获取值
field.setdata(value); //设置值
field.hide(); //隐藏字段
var id = field.json.id; //获取字段标识
var flag = field.isempty(); //字段是否为空
source
members
selectoro2.o2selector
人员选择框package的对象
type
-
o2.o2selector
example
//可以在脚本中获取该组件
var selector = this.form.get("fieldid").selector.selector; //获取人员选择框对象
var options = selector.options; //获取人员选择框的选项
source
descriptionnodeelement
描述信息节点,允许用户手工输入的组件才有此节点,只读情况下无此节点.
type
-
element
source
nodeelement
组件的节点,mootools封装过的dom对象,可以直接使用原生的js和moootools方法访问和操作该对象。
type
-
element
example
//可以在脚本中获取该组件
var field = this.form.get("fieldid"); //获取组件对象
field.node.setstyle("font-size","12px"); //给节点设置样式
source
jsonjsonobject
组件的配置信息,比如id,类型,是否只读等等。可以在组件的queryload事件里修改该配置来对组件做一些改变。
type
-
jsonobject
inherited from
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
formmwf.xapplication.process.xform.form
组件的所在表单对象.
type
inherited from
example
var form = this.form.get("fieldid").form; //获取组件所在表单对象
var container = form.container; //获取表单容器
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
inherited from
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
clickselect()
summary
弹出选择界面.
example
this.form.get('org').clickselect();
source
reload()
summary
重新加载组件。会执行postload事件。
inherited from
example
this.form.get("fieldid").reload(); //重新加载事件
source
isreadonly() → {boolean}
summary
判断组件是否只读.
returns
-
boolean
是否只读.
example
var readonly = this.form.get('subject').isreadonly();
source
isempty() → {boolean}
summary
判断组件值是否为空.
returns
-
boolean
值是否为空.
example
if( this.form.get('subject').isempty() ){
this.form.notice('标题不能为空', 'warn');
}
source
getdata()
summary
获取组件值。
description
在脚本中使用 this.data[fieldid] 也可以获取组件值。
区别如下:
1、当使用promise的时候
使用异步函数生成器(promise)为组件赋值的时候,用getdata方法立即获取数据,可能返回修改前的值,当promise执行完成以后,会返回修改后的值。
this.data[fieldid] 立即获取数据,可能获取到异步函数生成器,当promise执行完成以后,会返回修改后的值。
2、当表单上没有对应组件的时候,可以使用this.data[fieldid]获取值,但是this.form.get('fieldid')无法获取到组件。
inherited from
returns
-
组件的数据.
examples
var data = this.form.get('fieldid').getdata(); //没有使用promise的情况、
//如果无法确定表单上是否有组件,需要判断
var data;
if( this.form.get('fieldid') ){ //判断表单是否有无对应组件
data = this.form.get('fieldid').getdata();
}else{
data = this.data['fieldid']; //直接从数据中获取字段值
}
//使用promise的情况
var field = this.form.get("fieldid");
var dict = new this.dict("test"); //test为数据字典名称
var promise = dict.get("tools", true); //异步使用数据字典的get方法时返回promise,参数true表示异步
promise.then( function(){
var data = field.getdata(); //此时由于异步请求已经执行完毕,getdata方法获取到了数据字典的值
})
field.setdata( promise );
source
setdata(data, firechange)
summary
为组件赋值。
description
当参数为promise的时候,请参考文档:
当表单上没有对应组件的时候,可以使用this.data.add(fieldid, data, true) 赋值。
parameters
-
data
string
|promise
.
-
firechange
boolean
可选,是否触发change事件,默认false.
examples
this.form.get("fieldid").setdata("test"); //赋文本值
//如果无法确定表单上是否有组件,需要判断
if( this.form.get('fieldid') ){ //判断表单是否有无对应组件
this.form.get('fieldid').setdata( data );
}else{
this.data.add(fieldid, data, true);
}
//使用promise
var field = this.form.get("fieldid");
var dict = new this.dict("test"); //test为数据字典名称
var promise = dict.get("tools", true); //异步使用数据字典的get方法时返回promise,参数true表示异步
field.setdata( promise );
source
validate(routenameopt) → {boolean}
summary
根据组件的校验设置进行校验。
parameters
-
routename
string
可选,路由名称.
inherited from
returns
-
boolean
是否通过校验
example
if( !this.form.get('fieldid').validate() ){
return false;
}
source
getsource(typeopt) → {source|subsource|subsourceitem}
当前组件在数据源组件中时,可以通过此方法获取所在的上级数据源/子数据源/子数项组件.
parameters
-
type
string
需要获取的类型,"source"为表示数据源,"subsource"表示子数据源,"subsourceitem"表示子数据项组件。 如果该参数省略,则获取离当前组件最近的上述组件。
inherited from
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
需要获取的组件类型。 如果该参数省略,则获取离当前组件最近的祖先组件。type有效值如下:
form- 表单common- 通用组件datatable- 数据表格datatableline- 数据表格行datatemplate- 数据模板datatemplateline- 数据模板行div- 容器组件elcommon- element通用组件elcontainer- element容器组件subform- 子表单source- 数据源组件subsource- 子数据源subsourceitem- 子数据项组件tab- 分页组件tabpage- 分页组件的某个分页table- 表格tabletd- 单元格widget- 部件 -
validatefunction
function
进一步校验,参数为获取到匹配到类型的组件,返回false继续往上取对应类型的组件,返回true返回该组件。
inherited from
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
hide()
summary
隐藏组件.
inherited from
example
this.form.get("fieldid").hide(); //隐藏组件
source
show()
summary
显示组件.
inherited from
example
this.form.get("fieldid").show(); //显示组件
source
events
queryload
组件加载前触发。当前组件的queryload事件还没有在form里注册,通过this.form.get("fieldid")不能获取到当前组件,需要用this.target获取当前组件。
load
组件加载时触发.
postload
组件加载后触发.
change
当组件值改变时触发。
see
select
当组件不允许输入(使用人员选择框)时,完成选择人员,并且给组件赋值后执行。
see
queryloadselector
人员选择框事件:加载前执行。this.target指向人员选择框。
see
postloadselector
人员选择框事件:加载后执行,由于选择项为异步加载,此时选择项并未加载完成。this.target指向人员选择框。
see
queryloadcategory
人员选择框事件:加载选择框容器节点前执行。this.target指向人员选择框。
see
postloadcontent
人员选择框事件:加载选择框容器节点后执行。this.target指向人员选择框。
see
queryloadcategory
人员选择框事件:加载分类前执行。this.target指向分类,this.target.selector指向人员选择框。
see
postloadcategory
人员选择框事件:加载分类后执行。this.target指向分类,this.target.selector指向人员选择框。
see
selectcategory
人员选择框事件:选择分类后执行。this.target指向分类,this.target.selector指向人员选择框。
see
unselectcategory
人员选择框事件:取消选择分类后执行。this.target指向分类,this.target.selector指向人员选择框。
see
expand
人员选择框事件:展开分类后执行。this.target指向分类,this.target.selector指向人员选择框。
see
collapse
人员选择框事件:折叠分类后执行。this.target指向分类,this.target.selector指向人员选择框。
see
queryloaditem
人员选择框事件:加载选择项前执行。this.target指向选择项,this.target.selector指向人员选择框。
see
postloaditem
人员选择框事件:加载选择项后执行。this.target指向选择项,this.target.selector指向人员选择框。
see
selectitem
人员选择框事件:选择选择项后执行。this.target指向选择项,this.target.selector指向人员选择框。
see
unselectitem
人员选择框事件:取消选择选择项后执行。this.target指向选择项,this.target.selector指向人员选择框。
see
close
人员选择框事件:在人员选择框点取消时执行。this.target指向人员选择框。