ExtJS 2.0修改操作数据加载

来源:互联网 发布:理财软件哪个靠谱 编辑:程序博客网 时间:2024/06/06 08:24
Js代码 复制代码
  1. // 修改游戏信息  
  2.             function updataGame_form(data) {  
  3.                 // 游戏方式字段  
  4.                 var update_playtypeField = new Ext.form.ComboBox({  
  5.                     fieldLabel : '游戏方式',  
  6.                     name : 'playtype',  
  7.                     hiddenName : 'playtype',  
  8.                     allowBlank : false,  
  9.                     mode : 'local',  
  10.                     readOnly : true,  
  11.                     triggerAction : 'all',  
  12.                     anchor : '90%',  
  13.                     store : new Ext.data.SimpleStore({  
  14.                         fields : ['playtype''playtypename'],  
  15.                         data : [['0''单机'], ['1''网游']]  
  16.                     }),  
  17.                     valueField : 'playtype',  
  18.                     displayField : 'playtypename',  
  19.                     value : data.get('playtype')  
  20.                 });  
  21.                 var update_typeIdField = new Ext.form.ComboBox({  
  22.                     fieldLabel : '游戏类型',  
  23.                     name : 'typeId',  
  24.                     hiddenName : 'typeId',  
  25.                     allowBlank : false,  
  26.                     mode : 'local',  
  27.                     readOnly : true,  
  28.                     triggerAction : 'all',  
  29.                     anchor : '90%',  
  30.                     store :  
  31.   
  32.                     new Ext.data.Store({  
  33.                         autoLoad : true,  
  34.                         proxy : new Ext.data.HttpProxy({  
  35.                             url : 'listallgametype.action'  
  36.                         }),  
  37.                         reader : new Ext.data.JsonReader({  
  38.                             root : 'data'  
  39.                         }, [{  
  40.                             name : 'typeId',  
  41.                             mapping : 'typeId'  
  42.                         }, {  
  43.                             name : 'typeName',  
  44.                             mapping : 'typeName'  
  45.                         }]),  
  46.                         listeners : {  
  47.                             load : function() {  
  48.                                 update_typeIdField.setValue(data.get('typeId'));  
  49.                             }  
  50.                         }  
  51.                     }),  
  52.                     valueField : 'typeId',  
  53.                     displayField : 'typeName'  
  54.                 });  
  55.   
  56.                 return new Ext.FormPanel({  
  57.                     labelAlign : 'top',  
  58.                     frame : true,  
  59.                     width : 500,  
  60.                     fileUpload : true,  
  61.                     items : [{  
  62.                         layout : 'column',// 该FormPanel的layout布局模式为列模式(column),包含2列  
  63.                         items : [{// 第一列  
  64.                             columnWidth : 0.5,  
  65.                             layout : 'form',  
  66.                             items : [{  
  67.                                 xtype : 'textfield',  
  68.                                 fieldLabel : '游戏名称',  
  69.                                 name : 'gamename',  
  70.                                 allowBlank : false,  
  71.                                 anchor : '90%',  
  72.                                 value : data.get('gamename')  
  73.                             }, {  
  74.                                 xtype : 'textfield',  
  75.                                 fieldLabel : '开发商',  
  76.                                 name : 'developer',  
  77.                                 allowBlank : false,  
  78.                                 anchor : '90%',  
  79.                                 value : data.get('developer')  
  80.                             }, update_playtypeField]  
  81.   
  82.                         }, {    // 第二列  
  83.                             columnWidth : 0.5,  
  84.                             layout : 'form',  
  85.                             items : [{  
  86.                                 xtype : 'textfield',  
  87.                                 fieldLabel : '游戏编号',  
  88.                                 name : 'serial',  
  89.                                 allowBlank : false,  
  90.                                 anchor : '90%',  
  91.                                 value : data.get('serial')  
  92.                             }, {  
  93.                                 xtype : 'textfield',  
  94.                                 fieldLabel : '价格',  
  95.                                 name : 'price',  
  96.                                 allowBlank : false,  
  97.                                 anchor : '90%',  
  98.                                 value : data.get('price')  
  99.                             }, update_typeIdField]  
  100.                         }]  
  101.                     }, {  
  102.                         xtype : 'textfield',  
  103.                         fieldLabel : '游戏LOGO图片',  
  104.                         name : 'picture',  
  105.                         anchor : '90%',  
  106.                         height : 20,  
  107.                         inputType : 'file',  
  108.                         value : data.get('picture')  
  109.                     }, {  
  110.                         xtype : 'textarea',  
  111.                         fieldLabel : '游戏简介',  
  112.                         height : 140,  
  113.                         name : 'introduction',  
  114.                         allowBlank : false,  
  115.                         anchor : '90%',  
  116.                         value : data.get('introduction')  
  117.                     }, {  
  118.                         xtype : 'textfield',  
  119.                         fieldLabel : '百宝箱地址',  
  120.                         name : 'mboxurl',  
  121.                         allowBlank : false,  
  122.                         anchor : '90%',  
  123.                         value : data.get('mboxurl')  
  124.                     }]  
  125.                 });  
  126.             }  
  127.             function updateGameWin(grid) {  
  128.                 var record = grid.getSelectionModel().getSelected();  
  129.                 if (!record) {  
  130.                     Ext.Msg.alert("修改操作""请选择要修改的一项");  
  131.                 } else {  
  132.                     var updateGameFormWin;  
  133.                     var updateForm = updataGame_form(record);  
  134.                     if (!updateGameFormWin) {  
  135.   
  136.                         updateGameFormWin = new Ext.Window({  
  137.                             layout : 'fit',  
  138.                             width : 500,  
  139.                             height : 500,  
  140.                             closable : true,  
  141.                             closeAction : 'hide',  
  142.                             plain : true,  
  143.                             title : '修改游戏',  
  144.                             items : updateForm,  
  145.                             buttonAlign : 'center',  
  146.                             buttons : [{  
  147.                                 text : '修改',  
  148.                                 disabled : false,  
  149.                                 handler : function() {  
  150.                                     if (updateForm.form.isValid()) {  
  151.                                         updateForm.form.submit({  
  152.                                             url : 'updategame.action?gameid='  
  153.                                                     + record.get('gameid'),  
  154.                                             success : function(form, action) {  
  155.                                                 form.reset();  
  156.   
  157.                                                 if (action.result.msg == 'OK') {  
  158.                                                     Ext.MessageBox.alert('成功',  
  159.                                                             '修改游戏成功!');  
  160.                                                     this.store.reload({  
  161.                                                         params : {  
  162.                                                             start : 0,  
  163.                                                             limit : 10  
  164.                                                         }  
  165.                                                     });  
  166.                                                 } else {  
  167.                                                     Ext.Msg.alert('失败',  
  168.                                                             action.result.msg);  
  169.                                                 }  
  170.                                             },  
  171.                                             failure : function(form, action) {  
  172.                                                 Ext.MessageBox.alert('失败',  
  173.                                                         '修改游戏失败!');  
  174.                                             },  
  175.                                             waitMsg : '正在保存数据,稍后...'  
  176.                                         });  
  177.   
  178.                                         updateGameFormWin.hide();  
  179.                                     } else {  
  180.                                         Ext.Msg.alert('信息''请填写完成再提交!');  
  181.                                     }  
  182.                                 }  
  183.                             }, {  
  184.                                 text : '取消',  
  185.                                 handler : function() {  
  186.   
  187.                                     updateGameFormWin.hide();  
  188.   
  189.                                 }  
  190.                             }]  
  191.                         });  
  192.                     }  
  193.   
  194.                     updateGameFormWin.show(Ext.get('updateGameButton'));  
  195.   
  196.                 } 
原创粉丝点击