关键是这句:
win.on('beforedestroy', function(tab) {
typelist.remove(tab,false);
tab.hide();
return false;
});
网友原文章
- MyDesktop.TypeModule = Ext.extend(Ext.app.Module, {
- id:'type-win',
- init : function(){
- this.launcher = {text: '設備種類',iconCls:'icon-grid',handler : this.createWindow,scope: this}
- },
- createWindow : function(){
- var desktop = this.app.getDesktop();
- var win = desktop.getWindow('type-win');
- if(!win){
- win = desktop.createWindow({
- id: 'type-win',
- title:'設備種類',
- width:940,
- height:480,
- iconCls: 'icon-grid',
- shim:false,
- animCollapse:false,
- constrainHeader:true,
- loadMask: {msg:'正在加载数据,请稍侯……'},
- layout: 'fit',
- items:typelist
- })
- }
- win.on('beforedestroy', function(tab) { //关键所在
- typelist.remove(tab,false);
- tab.hide();
- return false;
- });
- win.show();
- }
- });
- var myPageSize=20; //grid 每頁顯示條數.常量.可以隨時更改為你需要顯示的條數.
- var selectBoxModel= new Ext.grid.CheckboxSelectionModel(); //多選框定義.
- // column model
- var typeCM = new Ext.grid.ColumnModel([
- selectBoxModel,
- {id: 'id', header: "種類編號", dataIndex: 'productstype_number',sortable: true},
- {header: "種類名稱", dataIndex: 'productstype_name',sortable: true},
- {header: "種類描述", dataIndex: 'productstype_description'}
- ]);
- typeCM.defaultSortable = false;
- //種類數據源
- var typeStore = new Ext.da
ta.Store({ - proxy:new Ext.da
ta.HttpProxy({url:"system/module/type/da ta/getTypeJsonData.php"}), - reader:new Ext.da
ta.JsonReader({ - totalProperty:"total",
- root:"results"
- },
- [{name:"productstype_id"},{name:"productstype_number"},{name:"productstype_name"},{name:"productstype_description"}]
- ),
- remoteSort: true
- });
- typeStore.load({params:{start:0, limit:myPageSize}});
- //查詢字段表單
- var searchTypeData=[['productstype_number','種類編號'],['productstype_name','種類名稱']]
- var searchTypeStore= new Ext.da
ta.SimpleStore({ - fields: ['value','text'],
- da
ta: searchTypeData - })
- var searchTypeCombo=new Ext.form.ComboBox({
- store:searchTypeStore,emptyText:'請 選 擇',mode: 'local',name:'fields',
- triggerAction: 'all',valueField: 'value',displayField: 'text',width:100
- });
- /**
- * @description 查詢關鍵字 文本輸入框
- */
- var searchTypeKeyword=new Ext.form.TextField({name:'keyword',emptyText:'請輸入查詢關鍵字'});
- // 这里很关键,如果不加,翻页后搜索条件就变没了,这里的意思是每次数据载入前先把搜索表单值加上去,这样就做到了翻页保留搜索条件了
- typeStore.on('beforeload',function(){
- Ext.apply(this.baseParams,
- {
- query:'query',
- keyword:searchTypeCombo.getValue(),
- queryValue:searchTypeKeyword.getValue()
- });
- });
- //菜單欄
- var typeMenubar = [{
- text:'新增',
- tooltip:'新增一個設備種類',
- iconCls:'add',
- handler: function(){
- new MyDesktop.Add({myOwner: typeStore});
- },
- scope: this
- },'-',{
- id: 'account-edit-button',
- text:'修改',
- tooltip:'编辑所选的项目',
- iconCls:'option',
- /* handler: function(){
- var record = Ext.getCmp('list-account-panel').getSelectionModel().getSelected();
- if(record ==null){
- Ext.Msg.alert('警告', '请选择一条记录!')
- }else{
- var da
ta = record.get('room_id'); - new MyDesktop.Edit({id: da
ta, myOwner: roomDataStore}); - }
- }, */
- scope: this
- },'-',{
- id: 'account-delete-button',
- text:'删除',
- tooltip:'删除当前选中记录数据',
- iconCls:'remove',
- /* handler:function(){
- var record = Ext.getCmp('list-account-panel').getSelectionModel().getSelected();
- if(record ==null){
- Ext.Msg.alert('警告', '请选择一条记录! ')
- }else{
- var roomid = record.get('room_id');
- Ext.Msg.confirm("请注意","确定删除该记录吗?",function(btn){
- if(btn=='yes'){
- Ext.MessageBox.show({
- msg : '正在请求数据,请稍后',processText : '正在请求数据',
- width : 300,wait : true,waitConfig : {interval : 200}
- });
- function successFn(){
- Ext.MessageBox.alert(' 提示','数据删除成功!');
- roomDataStore.reload();
- }
- function failureFn(){
- Ext.MessageBox.alert('提示','数据删除失败!');
- }
- Ext.Ajax.request({
- url : 'system/module/room/da
ta/delRoom.php', - params:{delData: roomid},
- success :successFn,failure :failureFn,
- scope: this
- });
- }else{
- return;
- }
- })
- }
- },*/
- scope: this
- },'-','','','','查 询:',searchTypeCombo,'',searchTypeKeyword,{
- iconCls: 'query',
- handler: function(){
- var fields=searchTypeCombo.getValue();
- var key=searchTypeKeyword.getValue();
- typeStore.reload({params:{start:0,limit:myPageSize,query:'query',keyword:fields,queryValue:key}});
- },
- scope: this
- }];
- //分頁導航
- var typePagingbar = new Ext.PagingToolbar({
- pageSize:myPageSize,
- store:typeStore,
- displayInfo: true,
- displayMsg: '显示第{0}条到第{1}条数据,总共{2}条数据',
- emptyMsg: "没有任何数据可以显示"
- });
- //列表
- var typelist=new Ext.grid.GridPanel({
- id: 'list-type-panel',
- border:false,
- ds:typeStore,
- cm: typeCM,
- viewConfig: {forceFit:true},
- tbar: typeMenubar,
- bbar: typePagingbar,
- enableColumnHide: true,
- stripeRows :true,
- layout: 'fit',
- loadMask: {msg: '正在载入数据...'},
- autoScroll:true,
- region:'center'
- });
- //鼠標雙擊彈出修改表單窗口.
- typelist.on('celldblclick', function(gridPanel, rowIndex, e) {
- var record = typelist.getStore().getAt(rowIndex); //Get the Record
- var da
ta = record.get('productstype_id'); - //new MyDesktop.Edit({id: da
ta, myOwner: roomDataStore}); - });
看陆川杨幂新片《琴棋书画》,品网易3D国韵网游《天下贰》