extjs4.1
Ext.window.Window第一次 设置 title属性给予赋值,第二次无效,通过 setTitle解决
Ext 常规新增/修改集成+表单验证操作
//grid columns
{ xtype : 'actioncolumn', text : '操作', align : 'center', items : [{ iconCls : 'deppon_icons_edit', tooltip : '修改', handler : function(gridView, rowIndex, colIndex) { var rowInfo = gridView.up('grid').getStore() .getAt(rowIndex); me.getFirstClassManageEditWindow().setOpt('update',rowInfo); } }
//grid tbar
{ text : '新增', xtype : 'button', handler : function() { var firstClassManageEditWindow = me.getFirstClassManageEditWindow(); firstClassManageEditWindow.setOpt('add'); firstClassManageEditWindow.show(); }
//window
//操作模式 opt:null, optUrl:null, setOpt:function(opt,record){ this.opt=opt; this.getEditFirstClassManageForm().getForm().reset(); if(opt=='update'){ this.getEditFirstClassManageForm().getForm().loadRecord(record); this.setTitle('编辑一级科目'); this.optUrl=mm.realPath('updateInfo.do'); this.show(); }else{ this.setTitle('添加一级科目'); this.optUrl=mm.realPath('addInfo.do'); } },
form items
{ xtype : 'textfield', name : 'projectCode', fieldLabel : '科目编号', maxLength : 16, allowBlank: false, validateOnBlur : true,
regex : /^[A-Za-z0-9]+$/, regexText : '该输入项只能输入数字和字母', validator:function(value){ if(value==''){ return true; } if(Ext.getCmp(mm.classManage.QUERY_mm_classManage_FRIST_RESULT_GRID_ID).getFirstClassManageEditWindow().opt=='update'){ return true; } var valid=false; Ext.Ajax.request({ url:mm.realPath('uniqueCheckByProjectCode.do'), params:{'projectCode':value}, async : false, success:function(response){ var result=Ext.JSON.decode(response.responseText); if(result.data==true){ valid= value+"重复"; }else{ valid=true; } }, failure:function(response){ var result=Ext.JSON.decode(response.responseText); Ext.ux.Toast.msg('提示',result.msg); } }); return valid; } }
window buttons
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
// 保存按钮 saveButton : null, getSaveButton : function() { var me = this; if (Ext.isEmpty(this.saveButton)) { this.saveButton = Ext.create('Ext.button.Button', { cls : 'yellow_button', text : '保存', handler : function() { var editFirstClassManageForm = me.getEditFirstClassManageForm().getForm(); // 校验产品表单 if (!editFirstClassManageForm.isValid()) { return; } var data = { id:editFirstClassManageForm.getValues()['id'].trim(), projectCode:editFirstClassManageForm.getValues()['projectCode'].trim(), projectName:editFirstClassManageForm.getValues()['projectName'].trim(), blFlag:editFirstClassManageForm.getValues()['blFlag'], regionLevel:"FRIST", regionParent :"MATTER" }; Ext.Ajax.request({ url : me.optUrl, params : data, success : function(response) { var result = Ext.JSON.decode(response.responseText); if (result.success) { Ext.ux.Toast.msg('提示', '保存成功'); me.close(); var grid = Ext .getCmp(mm.classManage.QUERY_mm_classManage_FRIST_RESULT_GRID_ID); grid.setVisible(true); grid.getPagingToolbar().moveFirst(); } else { Ext.ux.Toast.msg('提示', result.msg); } }, failure : function(response) { Ext.ux.Toast.msg('提示', response.responseText, 'error'); } }); } }); } return this.saveButton; },