BISubJectWin = function(winstores, thisgrid) { Winhander = this; //实例一个FormPanel类 form = new Ext.FormPanel({ region: "center", bodyStyle: "padding:5px", labelAlign: 'right', buttonAlign: 'center', items: [{ xtype: "textfield", name: "dictName", fieldLabel: "Name", maxLength: 4, allowBlank: false }, { xtype: "textfield", name: "dictDesc", fieldLabel: "Desc", width: 170, maxLength: 50, allowBlank: false }, { xtype: "textarea", name: "dictValue", fieldLabel: "Value", width: 200, maxLength: 200, height: 60 } ], buttons: [{ text: "提交", handler: function() { if (form.form.isValid()) { // throw sd; Test04.SaveData(form.form.getValues(), function(e, data) { if (data.result != null) { Ext.Msg.show ({ title: 'kkkkk', msg: e.message, buttons: Ext.Msg.OK, icon: Ext.MessageBox.WARNING }); if (data.result.result == true) { thisgrid.LoadData(); } } else { Ext.Msg.show ({ title: 'kkkkk', msg: '网络出现故障,请刷新页面!', buttons: Ext.Msg.OK, icon: Ext.MessageBox.WARNING }); } Winhander.close(); }); } } }, { text: "关闭", handler: function() { Winhander.close(); } }] }); //Form赋值 // var FormLoadData = function() { // form.disable(); // form.form.setValue(winstores.data); // form.enable(); // }; BISubJectWin.superclass.constructor.call(this, { id: 'SubJectWin', title: 'kkkkk', width: 350, height: 200, layout: "border", closeAction: 'close', modal: true, // 创建后窗口 遮罩 items: [form], listeners: { show: function() { if (winstores) { var typeid = new Ext.form.Hidden({ name: 'id' }); var typebillVer = new Ext.form.Hidden({ name: 'billVer' }); form.add(typeid); form.add(typebillVer); FormLoadData(); } } } }); }; Ext.extend(BISubJectWin, Ext.Window); //GRID BITest04 = function() { //定义自己的grid列 Colums = [new Ext.grid.RowNumberer({ width: 25 }), { header: 'Name', dataIndex: 'dictName', width: 150, editor: { xtype: 'textfield', allowBlank: false }, sortable: true }, { header: 'Desc', dataIndex: 'dictDesc', width: 200, editor: { xtype: 'textfield', allowBlank: false }, sortable: true }, { header: 'Value', dataIndex: 'dictValue', width: 200, editor: { xtype: 'textfield', allowBlank: false }, sortable: true}]; var editor = new Ext.ux.grid.RowEditor({ saveText: '更新', cancelText: '取消', clicksToEdit: 2, //点击鼠标几次触发更新 errorSummary: false }); editor.on({ scopr: this, afteredit: function(roweditor, changes, record, rowIndex) { //throw sd; Test04.SaveData(record.data, function(e, data) { if (e) { Ext.Msg.alert("提示", "更新成功"); } else { Ext.Msg.alert("提示", "更新成功"); //handler.LoadData(); } }); // Ext.Msg.alert("提示", "roweditor:" + roweditor + "__changes:" + changes + "record:" + record + "rowIndex:" + rowIndex + ""); } }); //定义自己的按钮 Tbars = [{ text: '增加', handler: function() { var win = Ext.getCmp("SubJectWin"); if (!win) { var win = new BISubJectWin(null, handler); } win.show(); } }, { text: '删除', handler: function() { Ext.Msg.confirm("系统提示", "确定要删除本条记录吗?", function(p) { if (p == "yes") { Test04.DelData(handler.getSelectionModel().getSelected().data.ID, function(e, data) { //throw aa; if (data.result != null) { Ext.Msg.show({ title: 'kkkkk', msg: e.message, buttons: Ext.Msg.OK, icon: Ext.MessageBox.WARNING }); if (data.result.result == true) { handler.LoadData(); } } else { Ext.Msg.show({ title: 'kkkkk', msg: '网络出现故障,请刷新页面!', buttons: Ext.Msg.OK, icon: Ext.MessageBox.WARNING }); } }); } }); } }, { text: '刷新', handler: function() { handler.LoadData(); } } ]; //使用JSON传入的数据源 JsonStores = new Ext.data.JsonStore({ fields: ['ID', 'dictName', 'dictDesc', 'dictValue']//数据源字段 }); this.LoadData = function() { //定义加载数据时 ,友情提示 "Please wait..." //var myMask = new Ext.LoadMask(el, { msg: "Please wait..." }); //myMask.show(); Test04.LoadAllDict(function(e, data) { JsonStores.removeAll(); //移除所有数据 JsonStores.loadData(data.result); //加载数据 //myMask.hide(); }); }; handler = this; BITest04.superclass.constructor.call(this, { frame: true, header: false, tbar: Tbars, columns: Colums, store: JsonStores, plugins: [editor] //直接修改 //弹出窗口式修改 // , // listeners: // { // rowdblclick: function(n, rowindex) { // var win = Ext.getCmp("SubJectWin"); // if (!win) { // var win = new BISubJectWin(JsonStores.getAt(rowindex), handler); // } // win.show(); // } // } }); this.LoadData(); //类实例化后加载数据 }; Ext.extend(BITest04, Ext.grid.GridPanel); test4 = function() { test4.superclass.constructor.call(this, { title: 'test4', id: 'test4', layout: 'fit', closable: true, items: [new BITest04()] }); } Ext.extend(test4, Ext.Panel);