var c_window = new Ext.Window({
title: 'title',
width: 950,
height: 530,
plain: true,
closeAction: 'hide',
defaults: {
anchor: '95%'
},
items:[user1],
modal: true,
buttons: [{
text: '关闭',
handler: function(){
c_window.hide();
}
}]
});Window控件的items初始化有一个项user1
如果再添加一个项user2?c_window.items.length=2;
c_window.items[1]=user2;//这样写不对
c_window.items.add(user2);//这样也不对
<script type="text/javascript">
var user1 = new Ext.form.TextField({
})
var user2= new Ext.form.TextField({
})
var c_window = new Ext.Window({
title: 'title',
width: 950,
height: 530,
plain: true,
closeAction: 'hide',
defaults: {
anchor: '95%'
},
items:[user1],
modal: true,
buttons: [{
text: '关闭',
handler: function(){
c_window.hide();
}
},{
text: '添加',
handler: function(){
c_window.add(user2); // 添加新组件
c_window.render(); // 添加后需要重新渲染一遍。
}
}]
});
c_window.show();
</script>
Adds Component(s) to this Container. Description : <ul class="mdetail-params"> Fires the beforeadd event before addin...
Adds Component(s) to this Container.Description : Fires the beforeadd event before adding
The Container's default config values will be applied accordingly (see defaults for details).
Fires the add event after the component has been added.
Notes : If the Container is already rendered when add is called, you may need to call doLayout to refresh the view which causes any unrendered child Components to be rendered. This is required so that you can add multiple child components if needed while only refreshing the layout once. For example:
var tb = new Ext.Toolbar();
tb.render(document.body); // toolbar is rendered
tb.add({text:'Button 1'}); // add multiple items (defaultType for Toolbar is 'button')
tb.add({text:'Button 2'});
tb.doLayout(); // refresh the layout
Warning: Containers directly managed by the BorderLayout layout manager may not be removed or added. See the Notes for BorderLayout for more details.
Parameters:
component : Object/Array
Either a single component or an Array of components to add. See items for additional information.(Optional) : Object
component_2
(Optional) : Object
component_n
Returns:
Ext.Component
component The Component (or config object) that was added.
Ext.dojoChina.demo.NewsWindow = function(_record,obj){
var _me = this ;
Ext.dojoChina.demo.NewsWindow.superclass.constructor.call(this, {
title:_record.get("LOGID"),
width: 500,
height:300,
resizable:false,
layout: "fit",
plain:true,
bodyStyle:"padding:5px;",
buttonAlign:"right",
buttons: [{
text: "关 闭",
handler:function(){
_me.close() ;
}
}],
items:[obj]
});
}
Ext.extend(Ext.dojoChina.demo.NewsWindow , Ext.Window) ;
------------------------------------------------------------------
var alertlog=new Ext.FormPanel({});
var record=this.getSelectionModel().getSelected();
var logwin = new Ext.dojoChina.demo.NewsWindow(record,alertlog) ;
logwin.show() ; 你可以吧那个record参数去掉
});
var user2= new Ext.form.TextField({
});
var user2= new Ext.form.TextField({
});
...
var items = [];
if(条件1){
items.push(user1);
}else if(条件2){
items.push(user2);
items.push(user3);
}
var c_window = new Ext.Window({
title: 'title',
width: 950,
height: 530,
plain: true,
closeAction: 'hide',
defaults: {
anchor: '95%'
},
items:items,
c_window.doLayout();