大家好我是全新的extjs和新的JavaScript。我嘗試着。我想要做的就是創建一個帶有各種屬性的面板表單的類,我希望能夠在需要調用myclass.makepanel時創建複製面板表單。我爲什麼要這麼做?我只是學習不同的東西,並逐漸熟悉ExtJS的,我不是想完成什麼特別,這是我到目前爲止的代碼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',但我不想這樣做,因爲我希望只要調用該類就能製作克隆表單。
這個類是沒有意義的,應該延長'Ext.form.Panel'和'initComponent' –