0
如何動態添加元素到面板中?如何在面板中添加ext元素
以下是創建面板代碼:
Ext.onReady(function(){
Ext.create('Ext.panel.Panel', {
renderTo: Ext.get('group-list'),
width: 520,
height: 400,
style: {
marginLeft: 'auto',
marginRight: 'auto'
},
title: 'Member List',
});
});
當我試圖
mainPanel.add(groupname);
mainPanel.doLayout();
這是行不通的,有什麼不對嗎?順便說一下,如何將數據加載到couchdb中並在面板中顯示它們?
這裏是所有的代碼:
function creategroup(){
var groupname = Ext.get('name').getValue();
var box = Ext.MessageBox.wait('Group Creation in progress, please wait', 'Please wait');
Ext.Ajax.request({
url : 'Controller',
params : {
'task' : 'groupcreate',
'action' : 'groupcreate',
'groupname' : groupname
},
success : function(response, opts) {
box.hide();
var obj = Ext.decode(response.responseText);
if (obj.status = 'Success'){
Ext.Msg.alert(obj.status, obj.message, function(btn, text){
if (btn == 'ok'){
// refreshPage();
mainPanel.add(groupname);
mainPanel.doLayout();
}
});
}
else{
Ext.Msg.alert(obj.status, obj.message, function(btn, text){
});
}
},
failure : function(response, opts) {
box.hide();
Ext.Msg.alert('Error', 'server-side failure with status code'
+ response.status);
}
});
}
爲什麼會這樣?你正在嘗試添加一個字符串,它期望一個組件配置/引用。 –
爲什麼人們使用doLayout()? – dbrin