在页面上有个grid表格 里面有个增加按钮,点击增加按钮时弹出一个窗口,填写相关信息 第一次点击增加按钮,窗口打开,可以关闭,第二次点击增加按钮后,弹出的窗口就不能关闭了.
截图是两次打开窗口的截图,第二次截图还多了几个下拉框 ,用的是extjs3.4的版本,改成extjs2.0的版本就正常了,是不是两个版本之间有什么区别,求指导
grid代码
var Record
CommonGrid = Ext
.extend(
Ext.grid.GridPanel,
{
// saveFlag : true,
constructor : function(cfg) {
var cfg = cfg || {};
Ext.apply(this, cfg);
var data = [
[ '10.21.34.56', '华为设备', '5680', 'aa', '1',
'1', '1', '1', '1', '1' ],
[ '10.21.34.56', '中兴设备', 'C200', 'aa', '2',
'1', '1', '1', '1', '1' ],
[ '10.21.34.56', '烽火设备', 'AN5616', 'aa', '2',
'2', '1', '1', '1', '1' ],
[ '10.21.34.56', '贝尔设备', 'AN5616', 'aa', '3',
'3', '1', '1', '1', '1' ] ];
var Record = Ext.data.Record.create([ {
name : 'logicid'
}, {
name : 'logiccode'
}, {
name : 'netproId'
}, {
name : 'logicname'
}, {
name : 'logicdec'
}, {
name : 'netproname'
}, {
name : 'netmodel'
}, {
name : 'bmodel'
}, {
name : 'ip'
}, {
name : 'port'
} ]);
this.NameCombo = new Ext.form.ComboBox({
id : 'nameCombo',
emptyText : "请选择...",
isFormField : true,
width : 100,
mode : 'local',
allowBlank : false,// 不允许为空
blankText : "不能为空",//
forceSelection : true,
triggerAction : 'all',
fieldLabel : "逻辑网元名称",
displayField : 'text',
listWidth : 100,
valueField : 'id',
store : new Ext.data.SimpleStore({
data : [ [ '1', '合肥' ], [ '2', '芜湖' ],
[ '3', '安庆' ], [ '4', '蚌埠' ] ],
fields : [ 'id', 'text' ]
}),
editable : false,// 不允许输入
});
this.ClassCombo = new Ext.form.ComboBox({
id : 'classCombo',
emptyText : "请选择...",
isFormField : true,
width : 100,
mode : 'local',
allowBlank : false,// 不允许为空
blankText : "不能为空",//
forceSelection : true,
triggerAction : 'all',
fieldLabel : "网元协议名称",
displayField : 'text',
listWidth : 100,
valueField : 'id',
store : new Ext.data.SimpleStore({
data : [ [ '1', '合肥' ], [ '2', '芜湖' ],
[ '3', '安庆' ], [ '4', '蚌埠' ] ],
fields : [ 'id', 'text' ]
}),
editable : false,// 不允许输入
});
this.store = new Ext.data.Store({
// proxy : new Ext.data.HttpProxy({url :
// 'getProcessRuleList.action', method : 'POST'}),
// reader : new Ext.data.JsonReader(
// {totalProperty:'total',root:'root'},
// [{name : 'id'},{name : 'busiTypeId'}, {name :
// 'busiType'}, {name
// : 'faultId'},
// {name : 'faultName'}, {name : 'accessWay'},{name
// : 'portType'},
// {name : 'processName'},
// {name : 'processchname'}, {name : 'createTime'}]
// )
autoLoad : true,
proxy : new Ext.data.MemoryProxy(data),// 获得本地数据
reader : new Ext.data.ArrayReader( // 解析数据
{}, Record
)
});
CommonGrid.superclass.constructor
.call(
this,
{
title : '网元信息列表',
id : '_processRuleConfig',
region : 'north',
height : 300,
border : false,
stripeRows : true,
split : true,
/*
* viewConfig:{ forceFit:true },
*/
cm : new Ext.grid.ColumnModel(
[
new Ext.grid.RowNumberer(),
{
header : '逻辑网元ID',
align : 'center',
dataIndex : 'logicid',
width : 150,
hidden : true
},
{
header : '逻辑网元编码',
align : 'center',
dataIndex : 'logiccode',
width : 150,
hidden : true
},
{
header : '网元协议ID',
align : 'center',
dataIndex : 'netproId',
width : 150,
hidden : true
},
{
header : '逻辑网元名称',
align : 'center',
dataIndex : 'logicname',
width : 150,
sortable : true
},
{
header : '逻辑网元描述',
align : 'center',
dataIndex : 'logicdec',
width : 150,
sortable : true
},
{
header : '网元协议名称',
align : 'center',
dataIndex : 'netproname',
width : 150,
renderer : this.detailInfoShow,
sortable : true
},
{
header : '网元交互模式',
align : 'center',
dataIndex : 'netmodel',
width : 150,
sortable : true
},
{
header : '部署模式',
align : 'center',
dataIndex : 'bmodel',
width : 150,
sortable : true
},
{
header : '服务IP',
align : 'center',
dataIndex : 'ip',
width : 150,
sortable : true
},
{
header : '服务端口',
align : 'center',
dataIndex : 'port',
width : 150,
sortable : true
} ]),
bbar : new Ext.PagingToolbar(
{
pageSize : 10,
store : this.store,
firstText : '第一页',
nextText : '下一页',
prevText : '上一页',
refreshText : '刷新',
lastText : '最后一页',
beforePageText : '当前',
afterPageText : '页/共{0}页',
displayInfo : true,
displayMsg : '显示第 {0} 条到 {1} 条记录,一共 {2} 条',
doLoad : function(C) { // 为了点击下一页传递参数用
var B = {};
var D = {};
A = this.paramNames;
B[A.start] = C;
B[A.limit] = this.pageSize;
if (this
.fireEvent(
"beforechange",
this,
B) !== false) {
this.store
.load({
params : B,
callback : function(
records,
option,
success) {
if (success) {
Ext
.getCmp("_processRuleConfig").store
.load({
params : B
});
}
}
});
}
},
emptyMsg : "没有记录",
items : [
' ',
{
text : '新增',
iconCls : 'new',
handler : this.doAdd,
scope : this
},
'-',
{
text : '修改',
iconCls : 'update',
handler : this.doModify,
scope : this
},
'-',
{
text : '删除',
iconCls : 'delete',
handler : this.doDelete,
scope : this
},
'-',
{
text : '配置命令模板',
iconCls : 'update',
handler : this.doCommand,
scope : this
},
'-',
{
text : '查看物理网元',
iconCls : 'find',
handler : this.doNet,
scope : this
} ]
}),
tbar : new Ext.Toolbar(
{
items : [
'逻辑网元名称:',
this.NameCombo,
'-',
'网元协议名称:',
this.ClassCombo,
'-',
{
text : '查询',
iconCls : 'find',
handler : this.doQuery,
scope : this
},
{
text : '重置',
iconCls : 'find',
handler : this.doClear,
scope : this
} ]
})
});
this.initListener();
},
initListener : function() {
this.addListener("render", function() {
this.loadMask = new Ext.LoadMask(Ext.getBody(), {
msg : '正在载入数据,请稍候...'
});
this.store.load({
params : {
start : 0,
limit : 5
}
});
}, this);
this.addListener("rowdblclick",
function(grid, index, e) {
this.doModify();
}, this);
this.addListener("cellclick", function(grid, index, e) {
this.doclick();
}, this);
},
detailInfoShow : function(val, medadata, record, rowIndex,
colIndex, store) {
// var testOrderId = record.get('testOrderId');
return "<a href='http://localhost:8080/extjs/jsp/netprotocol.jsp'>"
+ val + "</a>";
},
//窗口弹出代码
doAdd : function() {
if(Ext.getCmp('apWindow')!=null){
Ext.getCmp('apWindow').close();
var logicWindow = new LogicWindow({
pview : this
});
logicWindow.show();
}else{
var logicWindow = new LogicWindow({
pview : this
});
logicWindow.show();
}
},
doCommand : function() {
// 举例说明
window
.open(
"http://localhost:8080/extjs/jsp/netprotocol.jsp",
"_blank");
},
doNet : function() {
// 举例说明
window
.open(
"http://localhost:8080/extjs/jsp/netprotocol.jsp",
"_blank");
},
doclick : function() {
var record = this.getSelectionModel().getSelected();
var logicname = record.get("logicname");
this.ppanel.configRegion.rule.logicname
.setValue(logicname);
this.ppanel.configRegion.rule.logicname.disable();
},
doModify : function() {
var record = this.getSelectionModel().getSelected();
if (record == null) {
Ext.Msg.alert('系统提示', padBlank + padBlank
+ "请选择一条记录!" + padBlank + padBlank);
return;
}
var logicWindow = new LogicWindow({
pview : this
});
logicWindow.show();
logicWindow.logicForm.loadData(record);
},
doDelete : function() {
var record = this.getSelectionModel().getSelected();
if (record == null) {
Ext.Msg.alert('系统提示', padBlank + padBlank
+ "请选择一条记录!" + padBlank + padBlank);
return;
}
this.store.remove(record);
}
});
窗口代码
/**
* 逻辑网元信息配置窗口
*/
LogicWindow = Ext.extend(Ext.Window, {
constructor : function(cfg) {
var cfg = cfg || {};
Ext.apply(this, cfg);
this.logicForm = new RuleCommand({
pwin : this
});
LogicWindow.superclass.constructor.call(this, {
title : "逻辑网元信息配置",
id : 'apWindow',
resizable : false,
autoScroll : true,
width : 1100,
height : 300,
// bodyStyle : 'padding:5px 0px 5px 5px',
plain : true,
modal : true,
closeAction : 'close',
closable:true,
items : [ this.logicForm ],
// buttonAlign : 'center',
// buttons : [ {
// text : '添加',
// iconCls : 'save',
// handler : this.doSave,
// scope : this
// }, {
// text : '修改',
// iconCls : 'cancel',
// handler : this.doModify,
// scope : this
// }, {
// text : '重置',
// iconCls : 'find',
// handler : this.doClear,
// scope : this
// } ]
});
},
doClose : function() {
//this.pwin.close();
},
// /**
// * 保存信息
// */
doSave : function() {
var o = this.logicForm.getData();
if (o == null) {
Ext.MessageBox.alert("系统提示", padBlank + "请完善相关信息!" + padBlank);
return;
}
//this.store.insert(n, new Ext.data.Record(data));
var n=this.pview.store.getCount();
this.pview.store.insert(n, new Ext.data.Record(o));
this.doClose();
},
// /**
// * 添加公共信息
// */
// doInsert : function(o){
// var that = this ;
// ResApManager.saveAp(o,{
// callback:function(data){
// if(data == -1) {
// Ext.MessageBox.alert("系统提示", padBlank + "添加失败!" +padBlank);
// } else {
// that.doClose();
// Ext.MessageBox.alert("系统提示", padBlank + "添加成功!" +padBlank);
// that.pview.getStore().reload();
// }
// }
// });
// },
// /**
// * 修改公共信息
// */
// doUpdate : function(o){
// var that = this;
// ResApManager.updateAp(o,{
// callback: function(data) {
// if(data == -1) {
// Ext.MessageBox.alert("系统提示:", padBlank + "修改失败!" + padBlank);
// } else {
// that.doClose();
// Ext.MessageBox.alert("系统提示", padBlank + "修改成功!" + padBlank);
// that.pview.getStore().reload();
// }
// }
// });
// }
});
/**
* @author 网元协议配置
*/
// var update_Id = null;
/**
* @author 网元协议配置
*/
// var update_Id = null;
RuleCommand = Ext.extend(Ext.form.FormPanel, {
constructor : function(cfg) {
var cfg = cfg || {};
Ext.apply(this, cfg);
this.initialItems();
RuleCommand.superclass.constructor.call(this, {
layout : 'form',
region : 'center',
height : '250',
border : false,
frame : true,
split : true,
// viewConfig : {
// forceFit : true
// },
autoScroll : true,
buttonAlign : 'center',
buttons : [ {
text : '添加',
iconCls : 'save',
handler : this.doSave,
scope : this
}, {
text : '修改',
iconCls : 'cancel',
handler : this.doModify,
scope : this
}, {
text : '重置',
iconCls : 'find',
handler : this.doClear,
scope : this
} ]
// bodyStyle:'margin: 10 0 5px 10px;',
});
},
initialItems : function() {
this.logicname = new Ext.form.TextField({
fieldLabel : "逻辑网元名称",
width : 130,
length : 10,
allowBlank : false, // 不允许为空
blankText : '该项不能为空!'// 显示为空的提示信息
});
this.logiccode = new Ext.form.TextField({
fieldLabel : "逻辑网元编码",
width : 130,
length : 10,
allowBlank : false, // 不允许为空
blankText : '该项不能为空!'// 显示为空的提示信息
});
this.logicdec = new Ext.form.TextField({
fieldLabel : "逻辑网元描述",
width : 130,
length : 10,
allowBlank : false, // 不允许为空
blankText : '该项不能为空!'// 显示为空的提示信息
});
this.ip = new Ext.form.TextField({
fieldLabel : "服务IP",
width : 130,
length : 10,
allowBlank : false, // 不允许为空
blankText : '该项不能为空!'// 显示为空的提示信息
});
this.port = new Ext.form.TextField({
fieldLabel : "服务端口",
width : 130,
length : 10,
allowBlank : false, // 不允许为空
blankText : '该项不能为空!'// 显示为空的提示信息
});
this.netproname = new Ext.form.ComboBox({
id : 'netproname',
emptyText : "请选择...",
isFormField : true,
width : 130,
mode : 'local',
allowBlank : false,// 不允许为空
blankText : "不能为空",//
forceSelection : true,
triggerAction : 'all',
fieldLabel : "网元协议名称",
displayField : 'text',
listWidth : 100,
valueField : 'id',
store : new Ext.data.SimpleStore({
data : [ [ '1', '合肥' ], [ '2', '芜湖' ], [ '3', '安庆' ],
[ '4', '蚌埠' ] ],
fields : [ 'id', 'text' ]
}),
editable : false,// 不允许输入
});
this.netmodel = new Ext.form.ComboBox({
id : 'netmodel',
emptyText : "请选择...",
isFormField : true,
width : 130,
mode : 'local',
allowBlank : false,// 不允许为空
blankText : "不能为空",//
forceSelection : true,
triggerAction : 'all',
fieldLabel : "网元交互模式",
displayField : 'text',
listWidth : 100,
valueField : 'id',
store : new Ext.data.SimpleStore({
data : [ [ '1', '合肥' ], [ '2', '芜湖' ], [ '3', '安庆' ],
[ '4', '蚌埠' ] ],
fields : [ 'id', 'text' ]
}),
editable : false,// 不允许输入
});
this.bmodel = new Ext.form.ComboBox({
id : 'bmodel',
emptyText : "请选择...",
isFormField : true,
width : 130,
mode : 'local',
allowBlank : false,// 不允许为空
blankText : "不能为空",//
forceSelection : true,
triggerAction : 'all',
fieldLabel : "部署模式",
displayField : 'text',
listWidth : 100,
valueField : 'id',
store : new Ext.data.SimpleStore({
data : [ [ '1', '合肥' ], [ '2', '芜湖' ], [ '3', '安庆' ],
[ '4', '蚌埠' ] ],
fields : [ 'id', 'text' ]
}),
editable : false,// 不允许输入
});
this.fieldSet = new Ext.form.FieldSet({
title : '网元协议配置',
width : 1000,
height : 150,
style : 'margin: 10 0 5px 10px;',
items : [ {
xtype : 'panel',
layout : 'column',
style : 'margin: 10px 0px 0px 0px;',
items : [ {
columnWidth : .3,
layout : 'form',
labelWidth : 120,
items : this.logiccode
}, {
columnWidth : .3,
layout : 'form',
labelWidth : 120,
items : this.logicname
}, {
columnWidth : .3,
layout : 'form',
labelWidth : 120,
items : this.logicdec
} ]
}, {
xtype : 'panel',
layout : 'column',
style : 'margin: 0px 0px 0px 0px;',
items : [ {
columnWidth : .3,
layout : 'form',
labelWidth : 120,
items : this.netproname
}, {
columnWidth : .3,
layout : 'form',
labelWidth : 120,
items : this.netmodel
}, {
columnWidth : .3,
layout : 'form',
labelWidth : 120,
items : this.bmodel
} ]
}, {
xtype : 'panel',
layout : 'column',
items : [ {
columnWidth : .5,
layout : 'form',
labelWidth : 120,
style : 'margin: 0px 0px 0px 0px;',
items : this.port
}, {
columnWidth : .5,
layout : 'form',
labelWidth : 120,
style : 'margin: 0px 0px 0px 0px;',
items : this.ip
} ]
} ]
});
this.items = [ this.fieldSet ];
// this.items = [
//
//
//
// this.netComition,this.alarmContent,this.neNameCode,this.suceess,this.commandbak,this.neNameClass,this.flag,
// this.fault,this.falgs];
//
},
loadData : function(o) {
this.logiccode.setValue(o.data.logiccode);
this.logicname.setValue(o.data.logicname);
this.logicdec.setValue(o.data.logicdec);
this.netproname.setValue(o.data.netproname);
this.netmodel.setValue(o.data.netmodel);
this.bmodel.setValue(o.data.bmodel);
this.port.setValue(o.data.port);
this.ip.setValue(o.data.ip);
},
getData : function() {
if (this.getForm().isValid()) {
var logiccode = this.logiccode.getValue();
var logicname = this.logicname.getValue();
var logicdec = this.logicdec.getValue();
var netproname = this.netproname.getRawValue();
var netmodel = this.netmodel.getRawValue();
var bmodel = this.bmodel.getRawValue();
var port = this.port.getValue();
var ip = this.ip.getValue();
var o = {
logicname : logicname,
logicdec : logicdec,
netproname : netproname,
netmodel : netmodel,
bmodel : bmodel,
port : port,
ip : ip
};
return o;
} else {
Ext.Msg.alert("系统提示", "请完善相关信息");
return;
}
}
});