大家好,我是 extjs 的新手,也是 javascript 的新手。我正在努力。我想要做的是有一个类,它的方法可以制作具有各种属性的面板表单,我希望能够在我想要调用 myclass.makepanel 时制作克隆面板表单。我为什么要这样做?我只是在学习不同的东西并熟悉 extjs,我并没有特别尝试完成任何事情这是我的代码到目前为止
Ext.define('ryan', {
constructor: function () {
Ext.create('Ext.form.Panel', {
bodyStyle: {
"background-color": "green"
},
name: 'mypanel',
title: 'Animal sanctuary, one animal per location ',
width: 300,
bodyPadding: 10,
test: 'mycat',
style: 'background-color: #Fdd;',
renderTo: Ext.getBody(),
items: [{
id: 'button1',
xtype: 'button',
text: 'click the button',
handler: function () {
alert('(<^_^>)')
}
}, {
id: 'wildAnimal',
xtype: 'textfield',
fieldLabel: 'animal:',
name: 'myanimal'
}, { //end text field
id: 'myCombo',
xtype: 'combo',
fieldLabel: 'choose your animal',
store: animals,
queryMode: 'local',
displayField: 'name',
listeners: {
'change': function (field, selectedValue) {
Ext.getCmp('wildAnimal').setValue(selectedValue);
}
}
} // end combo
], //end items
}); // end .create
} // end ffunc
}); //end ryan
var animals = Ext.create('Ext.data.Store', {
fields: ['id', 'name'],
data: [{
"id": 'mycat',
"name": "mycat"
}, {
'id': 'mydog',
"name": "mydog"
}, {
'id': 'sbBarGirls',
"name": "BarGirls-when-drunk"
}]
}); //end animals.create // up to here no problems
Ext.onReady(ryan.constructor()); // can't actually display the panel.
我很抱歉格式没有直接从我的文本编辑器复制。因此,如果我的代码难以阅读,我可以再次发布。我可以将所有内容放在 .onReady 中,而不是尝试定义“ryan”,但我不想这样做,因为我希望能够通过调用类来制作克隆表单。