使用范围:UI2
class ViewComponent ($UI/system/lib/base/viewComponent) extends Component
可视组件基类
Constructor Top
ViewComponent () | |||
ViewComponent ( options) |
Static Properties & Enumerations Top
DATA_CHANGED
= "onDataChanged"
组件关联的数据项值变化事件 |
Properties Top
$domNode
组件关联的dom节点的jquery对象 | |||
domNode
组件关联的dom节点 |
Methods Top
void | addClass (String cls) | |
String | buildTemplate ( config) | |
Boolean | controlsDescendantBindings () | |
void | dispose () | |
ViewComponent | getComponentByCompID () | |
getElementByCompID () | ||
init ( value, bindingContext) | ||
void | inited () | |
void | processComponentAttr ( element, attrs) | |
void | removeClass (String cls) | |
void | setCSS (String css) | |
void | toggleClass (String cls) | |
void | update ( value, bindingContext) |
Constructor details
Top
public
ViewComponent
()
可视组件基类
public
ViewComponent
( options)
构造函数
参数options格式类似{parent:xx, config:{}},parent是组件的父节点,允许为空或不指定,config是组件的参数选项
public
ViewComponent
()
可视组件基类
public
ViewComponent
( options)
构造函数
参数options格式类似{parent:xx, config:{}},parent是组件的父节点,允许为空或不指定,config是组件的参数选项
Static Properties & Enumerations Detail Top
static
public
DATA_CHANGED
= "onDataChanged"
"onDataChanged"
组件关联的数据项值变化事件
事件对象的内容如下: { name: name, //数据项名称 value: value, //数据项新值 oldValue: oldValue, //数据项旧值 allValue: allValue, //所有数据项新值 allOldValue: allOldValue, //所有数据项旧值 source: this //组件自身 }
Properties Detail Top
public
$domNode
组件关联的dom节点的jquery对象
public
domNode
组件关联的dom节点
Methods Detail Top
public
void
addClass
(String cls)
组件节点上添加css class
public
String
buildTemplate
( config)
生成组件模板
参数config来自于new组件时参数{parent:xx, config:{}}中的config的值。 buildTemplate只有在js动态创建时才被调用,在W文件中声明使用组件时,组件模板通过服务端java解析; 支持js动态创建的组件必须重载buildTemplate方法。
public
Boolean
controlsDescendantBindings
()
组件是否自己控制子节点的数据绑定
如果组件自己控制子节点的数据绑定,界面引擎将不会遍历组件的子节点,需要 由组件自己处理。
public
void
dispose
()
析构函数
在当前组件的子节点中,根据compId查找组件
public
getElementByCompID
()
在当前组件的子节点中,根据compId查找节点
public
init
( value, bindingContext)
初始化组件
如果返回{ dependence:true}时,表示组件还没有初始化完成,它依赖其它组件,在要获取其其它组件 的promise的回调中调用当前组件的inited方法,通知界面引擎组件初始化完成。
public
void
inited
()
组件初始化完成
inited方法是给组件开发者使用的,用来标记组件已经初始化完成。大部分情况下组件开发者不需要调用这个 方法,只有当组件的init中需要依赖其它组件时,才需要在异步的回调中调用组件自身的inited标记当前组件已经 初始化完成。代码类似: init: function(value, bindingContext){ this.callParent(value, bindingContext); var self = this; this.getModel().componentPromise("otherComponentXid").done(function(otherComponent){ self.inited(); }).fail(function(err){ alert(err); }); return {dependence: true}; }
public
void
processComponentAttr
( element, attrs)
处理组件关联的数据项
public
void
removeClass
(String cls)
组件节点上删除css class
public
void
setCSS
(String css)
设置组件节点的样式
public
void
toggleClass
(String cls)
添加或删除组件节点上css class
public
void
update
( value, bindingContext)
更新组件
当组件关联的数据项的值发生改变时,会调用组件实例的update方法。