ExtJS 2.0修改操作数据加载
来源:互联网 发布:理财软件哪个靠谱 编辑:程序博客网 时间:2024/06/06 08:24
-
- function updataGame_form(data) {
-
- var update_playtypeField = new Ext.form.ComboBox({
- fieldLabel : '游戏方式',
- name : 'playtype',
- hiddenName : 'playtype',
- allowBlank : false,
- mode : 'local',
- readOnly : true,
- triggerAction : 'all',
- anchor : '90%',
- store : new Ext.data.SimpleStore({
- fields : ['playtype', 'playtypename'],
- data : [['0', '单机'], ['1', '网游']]
- }),
- valueField : 'playtype',
- displayField : 'playtypename',
- value : data.get('playtype')
- });
- var update_typeIdField = new Ext.form.ComboBox({
- fieldLabel : '游戏类型',
- name : 'typeId',
- hiddenName : 'typeId',
- allowBlank : false,
- mode : 'local',
- readOnly : true,
- triggerAction : 'all',
- anchor : '90%',
- store :
-
- new Ext.data.Store({
- autoLoad : true,
- proxy : new Ext.data.HttpProxy({
- url : 'listallgametype.action'
- }),
- reader : new Ext.data.JsonReader({
- root : 'data'
- }, [{
- name : 'typeId',
- mapping : 'typeId'
- }, {
- name : 'typeName',
- mapping : 'typeName'
- }]),
- listeners : {
- load : function() {
- update_typeIdField.setValue(data.get('typeId'));
- }
- }
- }),
- valueField : 'typeId',
- displayField : 'typeName'
- });
-
- return new Ext.FormPanel({
- labelAlign : 'top',
- frame : true,
- width : 500,
- fileUpload : true,
- items : [{
- layout : 'column',
- items : [{
- columnWidth : 0.5,
- layout : 'form',
- items : [{
- xtype : 'textfield',
- fieldLabel : '游戏名称',
- name : 'gamename',
- allowBlank : false,
- anchor : '90%',
- value : data.get('gamename')
- }, {
- xtype : 'textfield',
- fieldLabel : '开发商',
- name : 'developer',
- allowBlank : false,
- anchor : '90%',
- value : data.get('developer')
- }, update_playtypeField]
-
- }, {
- columnWidth : 0.5,
- layout : 'form',
- items : [{
- xtype : 'textfield',
- fieldLabel : '游戏编号',
- name : 'serial',
- allowBlank : false,
- anchor : '90%',
- value : data.get('serial')
- }, {
- xtype : 'textfield',
- fieldLabel : '价格',
- name : 'price',
- allowBlank : false,
- anchor : '90%',
- value : data.get('price')
- }, update_typeIdField]
- }]
- }, {
- xtype : 'textfield',
- fieldLabel : '游戏LOGO图片',
- name : 'picture',
- anchor : '90%',
- height : 20,
- inputType : 'file',
- value : data.get('picture')
- }, {
- xtype : 'textarea',
- fieldLabel : '游戏简介',
- height : 140,
- name : 'introduction',
- allowBlank : false,
- anchor : '90%',
- value : data.get('introduction')
- }, {
- xtype : 'textfield',
- fieldLabel : '百宝箱地址',
- name : 'mboxurl',
- allowBlank : false,
- anchor : '90%',
- value : data.get('mboxurl')
- }]
- });
- }
- function updateGameWin(grid) {
- var record = grid.getSelectionModel().getSelected();
- if (!record) {
- Ext.Msg.alert("修改操作", "请选择要修改的一项");
- } else {
- var updateGameFormWin;
- var updateForm = updataGame_form(record);
- if (!updateGameFormWin) {
-
- updateGameFormWin = new Ext.Window({
- layout : 'fit',
- width : 500,
- height : 500,
- closable : true,
- closeAction : 'hide',
- plain : true,
- title : '修改游戏',
- items : updateForm,
- buttonAlign : 'center',
- buttons : [{
- text : '修改',
- disabled : false,
- handler : function() {
- if (updateForm.form.isValid()) {
- updateForm.form.submit({
- url : 'updategame.action?gameid='
- + record.get('gameid'),
- success : function(form, action) {
- form.reset();
-
- if (action.result.msg == 'OK') {
- Ext.MessageBox.alert('成功',
- '修改游戏成功!');
- this.store.reload({
- params : {
- start : 0,
- limit : 10
- }
- });
- } else {
- Ext.Msg.alert('失败',
- action.result.msg);
- }
- },
- failure : function(form, action) {
- Ext.MessageBox.alert('失败',
- '修改游戏失败!');
- },
- waitMsg : '正在保存数据,稍后...'
- });
-
- updateGameFormWin.hide();
- } else {
- Ext.Msg.alert('信息', '请填写完成再提交!');
- }
- }
- }, {
- text : '取消',
- handler : function() {
-
- updateGameFormWin.hide();
-
- }
- }]
- });
- }
-
- updateGameFormWin.show(Ext.get('updateGameButton'));
-
- }