我要窗体自适应大小
窗体的高度可以自适应但是宽度不可以
Ext.QuickTips.init();
LoginWindow = Ext.extend(Ext.Window, {
id:'id',
renderTo : 'loginWin',
title : '登录系统',
width : 265,
height : 140,
autoHeight : true,
autoWidth:false,
closable : false,
resizable : false,
defaults : {
border : false
},
buttonAlign : "center",
createFormPanel : function() {
var loginPanel = new Ext.form.FormPanel( {
bodyStyle : 'padding-top:6px',
defaultType : 'textfield',
labelAlign : 'right',
labelWidth : 55,
labelPad : 0,
frame : true,
defaults : {
allowBlank : false,
width : 158
},
items : [ {
cls : 'user',
id : 'user',
name : 'usersQueryModel.name',
fieldLabel : '帐号',
blankText : '帐号不能为空'
}, {
cls : 'key',
name : 'usersQueryModel.password',
fieldLabel : '密码',
blankText : '密码不能为空',
inputType : 'password'
} ]
});
return loginPanel;
},
login : function() {
if (this.fp.form.isValid()) {
this.fp.form.submit( {
waitTitle : '请稍候',
waitMsg : '正在登录......',
url : 'userAction.do?action=login',
success : function(form, action) {
window.location.href = 'main.jsp';
},
failure : function(form, action) {
form.reset();
Ext.Msg.alert('警告', action.result.msg);
}
});
}
},
initComponent : function() {
LoginWindow.superclass.initComponent.call(this);
this.fp = this.createFormPanel();
this.add(this.fp);
this.addButton('登录', this.login, this);
this.addButton('重置', function() {
this.fp.form.reset();
}, this);
}
});Ext.onReady(function() {
var win = new LoginWindow();
win.show();
win.keys = new Ext.KeyMap(win.getEl(), {
key : 13,
fn : function() {
if (win.fp.form.isValid()) {
win.fp.form.submit( {
waitTitle : '请稍候',
waitMsg : '正在登录......',
url : 'userAction.do?action=login',
success : function(form, action) {
window.location.href = 'main.jsp';
},
failure : function(form, action) {
form.reset();
Ext.Msg.alert('警告', action.result.msg);
}
});
}
},
scope : win
});
setTimeout(function() {
Ext.get('loading-mask').fadeOut( {
remove : true
});
}, 300);
});

解决方案 »

  1.   

    LoginWindow = Ext.extend(Ext.Window, {
        id:'id',
        renderTo : 'loginWin',
        title : '登录系统',
        width : 265,
        height : 140,
        autoHeight : true,
        autoWidth:false,//autoWidth: true改成
        closable : false,
        resizable : false,
        defaults : {
            border : false
        },
        buttonAlign : "center",
      

  2.   

    LoginWindow = Ext.extend(Ext.Window, {
        id:'id',
        renderTo : 'loginWin',
        title : '登录系统',
        width : 265,
        height : 140,
       // autoHeight : true,
      //  autoWidth:false,
        closable : false,
        resizable : false,
        layout:"fit",
        defaults : {
            border : false
        },
      

  3.   


    window中的内容自动适应宽高就去掉默认的height、wdith
    LoginWindow = Ext.extend(Ext.Window, {
        id:'id',
        renderTo : 'loginWin',
        title : '登录系统',
        //width : 265,
        //height : 140,
        autoHeight : true,
        autoWidth:false,//autoWidth……
    在items中放些东西即可
      

  4.   


    renderTo : 'loginWin',
    title : '登录系统',
    items : {
    autoHeight : true,
    autoWidth : false
    },
    // width : 265,
    // height : 140,
    closable : false,
    resizable : false,
    buttonAlign : "center",
    defaults : {
    border : false
    },
    是这样的话还是不行