Ext Grid 동적 제거 삭제 tbar 구성 요소

6324 단어 grid

 /**
 * @include "../../common/Utils.js"
 */
Ext.define('app.view.performance.Home',{
	extend:'Ext.window.Window',
	alias:'widget.pfhome',
	title:'XXXXXX',
	modal : true,
    constrain:true,
    resizable:false,
    iconCls: 'jixiaoguanli',
	initComponent:function(){
		var me = this;
		var performanceds = Ext.create('app.store.PerFormances');
		var pfrecordds = Ext.create('app.store.PfRecords');
		Ext.applyIf(me,{
			width:1000,
			height:550,
			layout:'border',
			items:[{
				xtype:'treepanel',
				region:'west',
				store:Ext.create("Ext.data.TreeStore",{
						proxy:{
							url:'filtertrees/tree',
							extraParams:{menuId:'-20'},
							type:'ajax',
							reader:{
								type:'json',
								root:'items'
							}
						},
						root:{
							id:'tree-root',
							text:' ',
							expanded:true
						},
						autoLoad:true,
                        listeners:{
                            beforeload:function(store,opt){
                              var node = opt.node;
                              if(node.raw){
                                opt.params.type = node.raw.type; 
                                opt.params.id = node.raw.id;
                              }
                            }
                        }
					}),
				listeners:{
					itemdblclick:function(tp,record,item,index,evt,opt){
						var raw = record.raw;
						var grid = me.down('performancelist');
						if(raw.leaf){// 
								if(raw.type == "doubledate"){
									//show dateselector
								}else{
                                     if(raw.type=='month'){
                                    	Ext.create('app.view.base.MonthSelector',{
                                    		listeners:{
                                    			okhandler:function(str){
													var params = {};
													var vals = record.parentNode.raw||record.raw;
													if(vals.cnd=='='){
			                          					params[vals.fieldName]=str;
													}else if(vals.cnd=='cnd'){
														params['sql']=str;
													}else{
														params['sql']=app.Utils.getSqlBySelect(vals.cnd,vals.fieldName,str);
													}
													var proxy = grid.getStore().getProxy();
													var _url  = proxy.url;
													grid.getStore().setProxy({
														extraParams:params,
														url:_url,
														type:proxy.type,
														reader:proxy.reader
													});
													grid.getStore().load();
			                                    }
                                    		}
                                    	}).show();
                                    }else{
										var params = {};
										var vals = record.parentNode.raw||record.raw;
										if(vals.cnd=='='){
                          					params[vals.fieldName]=raw.value;
										}else if(vals.cnd=='cnd'){
											params['sql']=raw.value;
										}else{
											params['sql']=app.Utils.getSqlBySelect(vals.cnd,vals.fieldName,raw.value);
										}
										var proxy = grid.getStore().getProxy();
										var _url  = proxy.url;
										grid.getStore().setProxy({
											extraParams:params,
											url:_url,
											type:proxy.type,
											reader:proxy.reader
										});
										grid.getStore().load();
                                    }
								}
							}
					}
				},
				resizable:true,
				width:200
			},{
				xtype:'container',
				region:'center',
				layout:'anchor',
				defaults:{
					anchor:'100%'
				},
				items:[{
					xtype:'performancelist',
					height:250,
					store:performanceds,
					tbar:null,
					listeners:{
						afterrender:function(g){
							g.getStore().load({
								params:{empid:me['empid']}
							});
							return false;
						},
						itemdblclick:function(view,rec){
							pfrecordds.load({
								params:{
									empid:rec.get('empid'),
									sql:(" DATE_FORMAT(`times`,'%Y-%m') = '"+Ext.Date.format(Ext.Date.parse(rec.get('date'),
									app.Utils.DATE_FORMAT),'Y-m')+"'")
								}
							});
							return false;
						}
					}
				},{
					xtype:'pfrecordlist',
					height:267,
					store:pfrecordds,
					tbar:[{
						iconCls: 'add',
						text:' ',
						_sname:'add',
						handler:function(btn){
							me.fireEvent('addhandler',me,btn);
						}
					},'-',{
						iconCls: 'drop',
						text:' ',
						_sname:'remove',
						handler:function(btn){
							me.fireEvent('removehandler',me,btn);
						}
					},'-',{
						iconCls: 'tuichu',
						text:' ',
						handler:function(btn){
							me.close();
						}
					}]
				}]
			}]
		});
		me.callParent(arguments);
	}
});

 var view2 = Ext.create('app.view.performance.Home',{
					                		empid:record.get("empid")
					                	});
					                	view2.down("[xtype=container]").down("[xtype=pfrecordlist]").down("[_sname=add]").ownerCt.destroy();
										view2.show();

좋은 웹페이지 즐겨찾기