var fieldset = Ext.getCmp("user_sqlServerPermission"); fieldset.findById('datareader').setValue(true); /****************************************/ // 系统用户窗口定义 /** * @author ryan * 添加、编辑系统用户窗口定义 * */ DBE.userSqlServerPriGridPanel = function(config) { var user_sqlServerPermission= new Ext.form.FieldSet({ title : '用户权限分配', autoHeight : true, collapsible : true, id : 'user_sqlServerPermission', items : [{ layout : 'column', defaults : { hideLabels : true, layout : 'form' }, items : [{ columnWidth : .01 },{ columnWidth:.80, items:[new Ext.form.ComboBox({ id : 'dbNameCombo', xtype : 'combo', fieldLabel : ' 数据库名称', loadingText : 'Loading...', store : new Ext.data.JsonStore({ url : '../userOperateAction/getServerDBName.do', root : 'data', fields : ['id', 'dbName'] }), valueField : 'id', displayField : 'dbName', typeAhead : true, triggerAction : 'all', emptyText : '选择数据库名称', selectOnFocus : true, allowBlank : false, editable : false, forceSelection : true, name : 'dbNameCombo', listeners:{ "select":function(){ config.userInfo.dataBase = Ext.get("dbNameCombo").dom.value; //alert(Ext.get("datareader").checkbox.dom.checked ); //Ext.get("datareader").setValue(true); //document.getElementById("datareader").checked = true; //this.findField("datareader").setValue(true); //Ext.getCmp('datareader').dom.checked = true // 读取数据库信息,存储系统用户表的表名和系统用户表的路径 Ext.Ajax.request({ url : "../userOperateAction/getSysUserPriv.do", params: config.userInfo, success : function(response) { var json = response.responseText; var rst = eval("(" + json + ")"); var tableinfo = false; if ( rst.success ) { var fieldset = Ext.getCmp("user_sqlServerPermission"); fieldset.findById('datareader').setValue(true); /* if(Ext.get("datareader")== null) { //addCheckbox(rst.data); }else{ var fieldset = Ext.getCmp("user_sqlServerPermission"); //var datareader = Ext.get("datareader"); //alert(fieldset.findById('datareader').setValue(false)); fieldset.findById('datareader').setValue(false); //alert(Ext.get("sqlFormPanel").findField('datareader')); //fieldset.findField("datareader").setValue(false); //fieldset.items.remove(datareader); //fieldset.doLayout(); }*/ } }, failure : function(response) { var json = response.responseText; //alert("请求出错:" + json); DBE.infoTip(json); } }); } } })] }, { columnWidth : .33, items : [new Ext.form.Checkbox({ boxLabel : 'datareader', name : 'datareader', //inputValue :0, id:'datareader', checked : config.privInfo.insert, listeners: { check: function (obj, ischecked) { if(config.userInfo.dataBase == undefined) { alert("请选择数据库名称"); }else{ config.userInfo.privilege='db_datareader'; if (ischecked) { config.url='../userOperateAction/addSysUserPermission.do'; } else { config.url='../userOperateAction/deleteSysUserPermission.do'; } DBE.requestAction(config); } } } })] }, { columnWidth : .33, items : [new Ext.form.Checkbox({ boxLabel : 'datawriter', name : 'datawriter', id:'datawriter', //inputValue :0, checked : config.privInfo.update, listeners: { check: function (obj, ischecked) { if(config.userInfo.dataBase == undefined) { alert("请选择数据库名称"); }else{ config.userInfo.privilege='db_datawriter'; if (ischecked) { config.url='../userOperateAction/addSysUserPermission.do'; } else { config.url='../userOperateAction/deleteSysUserPermission.do'; } DBE.requestAction(config); } } } // disabled : true })] }/*, { columnWidth : .33, items : [new Ext.form.Checkbox({ boxLabel : 'Delete', name : 'delete', id:'delete', //inputValue :0, checked : config.privInfo.delete, listeners: { check: function (obj, ischecked) { config.userInfo.privilege='delete'; if (ischecked) { config.url='../userOperateAction/addSysUserPermission.do'; } else { config.url='../userOperateAction/deleteSysUserPermission.do'; } DBE.requestAction(config); } } //disabled : true })] }*/] }] }); function addCheckbox() { var fieldset = Ext.getCmp("user_sqlServerPermission"); var priCheckbox = new Ext.form.Checkbox({ boxLabel : 'datareader', name : 'datareader', //inputValue :0, id:'datareader', checked : true, columnWidth:.40, listeners: { check: function (obj, ischecked) { /* if(config.userInfo.dataBase == undefined) { alert("请选择数据库名称"); }else{ config.userInfo.privilege='db_datareader'; if (ischecked) { config.url='../userOperateAction/addSysUserPermission.do'; } else { config.url='../userOperateAction/deleteSysUserPermission.do'; } DBE.requestAction(config); }*/ alert("ok"); } } }); fieldset.add(priCheckbox); fieldset.doLayout(); //var sqlServerPermission = Ext.get("user_sqlServerPermission"); //Ext.get("user_sqlServerPermission").appendChild("datareader"); }; var userForm = new Ext.form.FormPanel({ defaultType : 'textfield',//表单默认类型,必须属性 labelAlign : 'center',//位置 id:"sqlFormPanel", frame : true, url : config.editUrl, reader : new Ext.data.JsonReader({ root : 'root' }, [{ name : 'userName',mapping:'userName' }]), items:[{ id : 'userName', fieldLabel : ' 用户名', allowBlank : false, value : config.userInfo.userName, name : 'userName', disabled : true, readOnly:true, width:200 },user_sqlServerPermission], buttons : [/*{ text : '确定', scope : this, handler : function() { var select_value = Ext.get('select').dom.checked; var insert_value = Ext.get('insert').dom.checked; var update_value = Ext.get('update').dom.checked; var delete_value = Ext.get('delete').dom.checked; config.userInfo.select=select_value; config.userInfo.insert=insert_value; config.userInfo.update=update_value; config.userInfo.delete=delete_value; //alert(value); this.submit(config); } },*/{ text : '关闭', scope : this, handler : function() { this.close(); } }], keys : [{ key : [10, 13], scope : this, fn : function() { this.submit(); } }], Checkbox:[{ fieldLabel : ' 用户权限', }] }); if(config.editUrl != undefined) { userForm.form.load(); } //config.jsonds.load(); // def config params var cfg = { id: 'user_sqlServerPermissionWindow', title : config.title, layout : 'fit', height : 200, width : 300, plain : true, frame : true, border : false, modal : true, draggable : false, resizable : false, closable : true, items : userForm }; config = Ext.applyIf(config || {}, cfg); // call superclass DBE.userSqlServerPriGridPanel.superclass.constructor.call(this, config); // 公布属性 this.userForm = userForm; this.successCallback = false;// 登录成功后的回调 } Ext.extend(DBE.userSqlServerPriGridPanel, Ext.Window, { /** * 显示窗口,并且自动大小 */ showToCenter : function(animateTarget) { var self = this; this.show(animateTarget, function() { var size = Ext.getBody().getSize(true); size.width = size.width / 3; size.height = size.height / 3; // 校正高度 //var oheight = size.height + 150; size.height = size.height + 60; self.setSize(size); self.getEl().center(); }); }, submit : function(config) { var form = this.userForm.getForm(); if (form.isValid()) { // alert('login...'); form.doAction('submit', { url : config.url, method : 'post', waitTitle : '请稍等', waitMsg : '数据提交中……', scope : this, params:config.userInfo, success : function(form, action) { var rst = action.result; //var rst = eval("(" + json + ")"); if ( rst.success ) { var msg = rst.msg ? rst.msg : Ext.encode(rst); //alert('请求失败:' + msg); //Ext.QuickTips.init(); DBE.infoTip(msg); if(config.tabUserGrid != undefined) { config.tabUserGrid.store.reload(); } } if (this.successCallback) { this.successCallback(); } this.close(); // 为Ajax注册事件Handle DBE.initAjaxListeners(); }, failure : function(form, action) { var rst = action.result; if(rst == undefined) { DBE.infoTip("执行操作失败"); return; } DBE.infoTip(rst.msg); /* Ext.Msg.info({ message : rst.msg, alignRef : 'userWindow', alignType : 'tl-tr?' });*/ } }); } else { // alert('数据填写不完整~~!'); Ext.Msg.info({ message : '数据填写不完整~~!', alignRef : 'userWindow', alignType : 'tl-tr?' }); } } }); 直接用FormPanel的find系列方法:find、fingBy、findById等等。