gridpanel 第一次显示内容 第二次无法显示

关键是这句:
   win.on('beforedestroy'function(tab) {      

            typelist.remove(tab,false);      

            tab.hide();      

            return false;      

       }); 

 
网友原文章
  1. MyDesktop.TypeModule = Ext.extend(Ext.app.Module, {   
  2.     id:'type-win',   
  3.     init : function(){   
  4.         this.launcher = {text: '設備種類',iconCls:'icon-grid',handler : this.createWindow,scope: this}   
  5.     },   
  6.     createWindow : function(){   
  7.         var desktop = this.app.getDesktop();   
  8.         var win = desktop.getWindow('type-win');   
  9.         if(!win){   
  10.             win = desktop.createWindow({   
  11.                 id: 'type-win',   
  12.                 title:'設備種類',   
  13.                 width:940,   
  14.                 height:480,   
  15.                 iconCls: 'icon-grid',   
  16.                 shim:false,   
  17.                 animCollapse:false,   
  18.                 constrainHeader:true,   
  19.                 loadMask: {msg:'正在加载数据,请稍侯……'},   
  20.                 layout: 'fit',   
  21.                 items:typelist   
  22.             })   
  23.         }   
  24.        win.on('beforedestroy'function(tab) {      //关键所在
  25.             typelist.remove(tab,false);      
  26.             tab.hide();      
  27.             return false;      
  28.        });                                           
  29.        win.show();   
  30.     }   
  31. });   
  32.   
  33.   
  34.   
  35. var myPageSize=20;      //grid 每頁顯示條數.常量.可以隨時更改為你需要顯示的條數.   
  36. var selectBoxModel= new Ext.grid.CheckboxSelectionModel();  //多選框定義.   
  37.   
  38. // column model   
  39. var typeCM = new Ext.grid.ColumnModel([   
  40.     selectBoxModel,   
  41.     {id: 'id', header: "種類編號", dataIndex: 'productstype_number',sortable: true},   
  42.     {header: "種類名稱", dataIndex: 'productstype_name',sortable: true},   
  43.     {header: "種類描述", dataIndex: 'productstype_description'}   
  44. ]);   
  45. typeCM.defaultSortable = false;   
  46. //種類數據源   
  47. var typeStore = new Ext.data.Store({   
  48.     proxy:new Ext.data.HttpProxy({url:"system/module/type/data/getTypeJsonData.php"}),   
  49.     reader:new Ext.data.JsonReader({   
  50.         totalProperty:"total",   
  51.         root:"results"  
  52.     },   
  53.     [{name:"productstype_id"},{name:"productstype_number"},{name:"productstype_name"},{name:"productstype_description"}]   
  54.     ),   
  55.     remoteSort: true  
  56. });   
  57. typeStore.load({params:{start:0, limit:myPageSize}});   
  58. //查詢字段表單   
  59. var searchTypeData=[['productstype_number','種類編號'],['productstype_name','種類名稱']]   
  60. var searchTypeStore= new Ext.data.SimpleStore({   
  61.     fields: ['value','text'],   
  62.     data: searchTypeData   
  63. })   
  64. var searchTypeCombo=new Ext.form.ComboBox({   
  65.         store:searchTypeStore,emptyText:'請 選 擇',mode: 'local',name:'fields',   
  66.         triggerAction: 'all',valueField: 'value',displayField: 'text',width:100   
  67.     });   
  68. /**  
  69.  * @description 查詢關鍵字 文本輸入框  
  70.  */  
  71. var searchTypeKeyword=new Ext.form.TextField({name:'keyword',emptyText:'請輸入查詢關鍵字'});   
  72. // 这里很关键,如果不加,翻页后搜索条件就变没了,这里的意思是每次数据载入前先把搜索表单值加上去,这样就做到了翻页保留搜索条件了   
  73. typeStore.on('beforeload',function(){   
  74.     Ext.apply(this.baseParams,   
  75.     {   
  76.         query:'query',   
  77.         keyword:searchTypeCombo.getValue(),   
  78.         queryValue:searchTypeKeyword.getValue()   
  79.     });   
  80. });   
  81. //菜單欄   
  82. var typeMenubar = [{   
  83.         text:'新增',   
  84.         tooltip:'新增一個設備種類',   
  85.         iconCls:'add',   
  86.         handler: function(){   
  87.             new MyDesktop.Add({myOwner: typeStore});   
  88.         },   
  89.         scope: this  
  90.     },'-',{   
  91.         id: 'account-edit-button',   
  92.         text:'修改',   
  93.         tooltip:'编辑所选的项目',   
  94.         iconCls:'option',   
  95. /*      handler: function(){  
  96.             var record = Ext.getCmp('list-account-panel').getSelectionModel().getSelected();  
  97.             if(record ==null){  
  98.                 Ext.Msg.alert('警告', '请选择一条记录!')  
  99.             }else{  
  100.                 var data = record.get('room_id');  
  101.                 new MyDesktop.Edit({id: data, myOwner: roomDataStore});  
  102.             }  
  103.         }, */          
  104.         scope: this  
  105.     },'-',{   
  106.         id: 'account-delete-button',   
  107.         text:'删除',   
  108.         tooltip:'删除当前选中记录数据',   
  109.         iconCls:'remove',    
  110. /*      handler:function(){  
  111.             var record = Ext.getCmp('list-account-panel').getSelectionModel().getSelected();  
  112.             if(record ==null){  
  113.                 Ext.Msg.alert('警告', '请选择一条记录!       ')  
  114.             }else{  
  115.                 var roomid = record.get('room_id');           
  116.                 Ext.Msg.confirm("请注意","确定删除该记录吗?",function(btn){  
  117.                     if(btn=='yes'){  
  118.                          Ext.MessageBox.show({  
  119.                            msg : '正在请求数据,请稍后',processText : '正在请求数据',  
  120.                            width : 300,wait : true,waitConfig : {interval : 200}                
  121.                          });  
  122.                          function successFn(){                           
  123.                               Ext.MessageBox.alert(' 提示','数据删除成功!');  
  124.                               roomDataStore.reload();  
  125.                          }  
  126.                          function failureFn(){  
  127.                               Ext.MessageBox.alert('提示','数据删除失败!');  
  128.                          }                             
  129.                          Ext.Ajax.request({  
  130.                             url : 'system/module/room/data/delRoom.php',  
  131.                             params:{delData: roomid},  
  132.                             success :successFn,failure :failureFn,  
  133.                             scope: this  
  134.                         });   
  135.                     }else{  
  136.                         return;  
  137.                     }  
  138.                 })  
  139.         }             
  140.      },*/  
  141.         scope: this  
  142.     },'-','','','','查 询:',searchTypeCombo,'',searchTypeKeyword,{   
  143.         iconCls: 'query',   
  144.         handler: function(){   
  145.             var fields=searchTypeCombo.getValue();   
  146.             var key=searchTypeKeyword.getValue();   
  147.             typeStore.reload({params:{start:0,limit:myPageSize,query:'query',keyword:fields,queryValue:key}});             
  148.         },         
  149.         scope: this  
  150.     }];   
  151. //分頁導航     
  152. var typePagingbar = new Ext.PagingToolbar({   
  153.     pageSize:myPageSize,   
  154.     store:typeStore,   
  155.     displayInfo: true,   
  156.     displayMsg: '显示第{0}条到第{1}条数据,总共{2}条数据',   
  157.     emptyMsg: "没有任何数据可以显示"  
  158. });    
  159. //列表   
  160. var typelist=new Ext.grid.GridPanel({   
  161.     id: 'list-type-panel',    
  162.     border:false,   
  163.     ds:typeStore,   
  164.     cm: typeCM,   
  165.     viewConfig: {forceFit:true},   
  166.     tbar: typeMenubar,        
  167.     bbar: typePagingbar,   
  168.     enableColumnHide: true,   
  169.     stripeRows :true,   
  170.     layout: 'fit',   
  171.     loadMask: {msg: '正在载入数据...'},   
  172.     autoScroll:true,   
  173.     region:'center'  
  174. });    
  175.   
  176. //鼠標雙擊彈出修改表單窗口.   
  177. typelist.on('celldblclick'function(gridPanel, rowIndex, e) {         
  178.     var record = typelist.getStore().getAt(rowIndex);   //Get the Record   
  179.     var data = record.get('productstype_id');                  
  180.     //new MyDesktop.Edit({id: data, myOwner: roomDataStore});   
  181. });  



看陆川杨幂新片《琴棋书画》,品网易3D国韵网游《天下贰》
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值