2010-03-29 52 views
1

我使用json例如从服务器返回的字段动态创建表单。数据extjs将插件添加到动态表单域

"items": [ 
    {"xtype": "textfield", "fieldLabel": "Name", "name": "name"}, 
    {"xtype": "textfield", "fieldLabel": "Description", "name": "description"}, 
    {"xtype": "textarea", "fieldLabel": "Text", "name": "text"} 
], 

现在我想自定义插件添加到每个字段通常在客户端上我做这个

plugins:new Ext.ux.plugins.MyPlugin() 

但我的表单字段从服务器来了,我怎么能加入插件,领域例如像这样(但不工作)

"plugins": "Ext.ux.plugins.MyPlugin" 

回答

4

你也可以用“p型”注册插件:


MyPlug = Ext.extend(Object, { 
    init : function(c){ 
     console.log('fire'); 
    } 
}); 
Ext.preg('myplug', MyPlug); 

new Ext.Component({ 
    plugins: [{ptype: 'myplug'}] 
}); 
+0

感谢看起来不错,但它是记录? – 2010-03-29 08:56:05

+0

http://www.extjs.com/deploy/dev/docs/?class=Ext.ComponentMgr&member=registerPlugin – 2010-03-29 22:29:24