问题描述
Ext window:var addWin = Ext.create('Ext.window.Window', {title : '角色添加',id : 'addWin',layout : "column",border : false,autoDestroy : false,width : 450,height : 250,closeAction : 'hide',plain : true,modal : true,constrain : true,items : addForm});Ext formPanel: var addForm = Ext.create('Ext.form.Panel', {title : 'Simple Form',id : 'addForm',frame : true,monitorValid : true,bodyStyle : 'padding:5px 5px 0',//layout : 'form',fieldDefaults : {labelAlign : 'top',msgTarget : 'side'},//url : ctxpath + '/SystemManager/RoleList',defaultType : 'textfield',items : [ {fieldLabel : '角色编号',name : 'first',allowBlank : false}, {fieldLabel : '角色名',name : 'last',allowBlank : false} ],buttons : [ {text : '重置',handler : function() {//addForm.getForm().reset();}}, {text : '提交',formBind : true, //only enabled once the form is validdisabled : true,handler : function() {//var form = addForm.getForm();//if (form.isValid()) {//form.submit( {//success : function(form, action) {//Ext.Msg.alert('Success', '1');//},//failure : function(form, action) {//Ext.Msg.alert('Failed', '2');//}//});//}}} ]});点击新增时,window可以展示,但是window中的formPanel不能显示。如图: 问题补充:<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%><%String path = request.getContextPath();String basePath = request.getScheme() + "://"+ request.getServerName() + ":" + request.getServerPort()+ path + "/";%><html><head><link rel="stylesheet" type="text/css"href="ext-4.1/resources/css/ext-all.css" /><link rel="stylesheet" type="text/css"href="ext-4.0/my_css/button.css" "/><script type="text/javascript" src="ext-4.1/bootstrap.js"></script><script type="text/javascript"src="ext-4.1/locale/ext-lang-zh_CN.js"></script><script type="text/javascript">Ext.onReady(function() { var addWin = Ext.create('Ext.window.Window', {title : '角色添加',id : 'addWin',layout : "fit",autoDestroy : false,width : 450,height : 250,//x:100,//y:100,closeAction : 'hide',plain : true,modal : true,constrain : true,items : addForm}).show();//添加角色formvar addForm = Ext.create('Ext.form.Panel', {title : 'Simple Form',id : 'addForm',frame : true,border :false,monitorValid : true,width:250,heigth:200,//x:150,//y:150,layout:'fit',bodyStyle : 'padding:5px 5px 0',fieldDefaults : {labelAlign : 'top',msgTarget : 'side'},//url : ctxpath + '/SystemManager/RoleList',defaultType : 'textfield',items : [ {fieldLabel : '角色编号',name : 'role.pk_juese',allowBlank : false}, {fieldLabel : '角色名',name : 'role.juesename',allowBlank : false} ],buttons : [ {text : '重置',handler : function() {//addForm.getForm().reset();}}, {text : '提交',formBind : true, disabled : true,handler : function() {//var form = addForm.getForm();//if (form.isValid()) {//form.submit( {//success : function(form, action) {//Ext.Msg.alert('Success', '1');//},//failure : function(form, action) {//Ext.Msg.alert('Failed', '2');//}//});//}}} ]});});</script></head><body>This is my JSP page.<br></body></html>我已经将window,form放到一个页面中了。
解决方案
先写addForm ,再写addWin <html> <head> <link rel="stylesheet" type="text/css" href="ext-all.css" /> <script type="text/javascript" src="bootstrap.js"> </script> <script type="text/javascript" src="ext-lang-zh_CN.js"> </script> <script type="text/javascript"> Ext.onReady(function() { //添加角色form var addForm = Ext.create('Ext.form.Panel', { title : 'Simple Form', id : 'addForm', frame : true, border :false, monitorValid : true, width:250, heigth:200, //x:150, //y:150, layout:'fit', bodyStyle : 'padding:5px 5px 0', fieldDefaults : { labelAlign : 'top', msgTarget : 'side' }, //url : ctxpath + '/SystemManager/RoleList', defaultType : 'textfield', items : [ { fieldLabel : '角色编号', name : 'role.pk_juese', allowBlank : false }, { fieldLabel : '角色名', name : 'role.juesename', allowBlank : false } ], buttons : [ { text : '重置', handler : function() { //addForm.getForm().reset(); } }, { text : '提交', formBind : true, disabled : true, handler : function() { // var form = addForm.getForm(); // if (form.isValid()) { // form.submit( { // success : function(form, action) { // Ext.Msg.alert('Success', '1'); // }, // failure : function(form, action) { // Ext.Msg.alert('Failed', '2'); // } // }); // } } } ] });var addWin = Ext.create('Ext.window.Window', { title : '角色添加', id : 'addWin', layout : "fit", autoDestroy : false, width : 450, height : 250, //x:100, //y:100, closeAction : 'hide', plain : true, modal : true, constrain : true, items : addForm }).show(); }); </script> </head> <body> This is my JSP page. <br> </body> </html>
解决方案二:
layout : "fit",