日期:2014-05-16  浏览次数:20420 次

extjs 增删改查
App.tabs.eduHighRiskGravida = (function(){
	var limit = 20,tabId = "eduHighRiskGravidaTab",addOrUpdateWin = null, acrWin = null, aclWin = null;
	function init(){
		 
		var curPanel = Ext.getCmp('tabsPanel');
		var store = new Ext.data.Store({
			autoLoad:false,
			proxy:new Ext.data.HttpProxy({url:App.baseURL+'/eduHighRiskGravida/findPage'}),
			reader:new Ext.data.JsonReader({
				totalProperty:'totalCount',
				root:'datas',
				idProperty:'id',
				fields:[{name:'id'},{name:'week1'},{name:'week2'},{name:'content'},{name:'statue'},{name:'highRiskName'},{name:'highRiskId'},{name:'highRiskState'}]
			}),
			baseParams:{start:0,limit:limit,field:'',keyword:''},
			listeners:{
				loadexception:function(proxy,type,action,options,response){
					App.failureCallback(action);
				}
			}	
		}),
		sm = new Ext.grid.CheckboxSelectionModel({singleSelect:false}),
		cm = new Ext.grid.ColumnModel([new Ext.grid.RowNumberer(),sm,
			{header : '因          素',dataIndex : 'highRiskName',sortable : true,width : 200},
			{header : '时间范围',dataIndex : 'week1',sortable : true,width : 200,renderer:function(value, metaData, record, rowIndex, colIndex, store){
				return record.get('week1')+" -  "+ record.get('week2') ; 
			}},
			{header : '指导内容',dataIndex : 'content',sortable : true,width : 200} 
		]),
		grid = new Ext.grid.GridPanel({
			id:'eduHighRiskGravidaGrid',
			border : false,
			columnLines : true,
			autoScroll : true,
			store : store,
			autoHeight:false,
			stripeRows:true,
			cm : cm,
			sm : sm,
			loadMask : {msg : CONST.TIP017},
			bbar:new Ext.PagingToolbar({
				pageSize : limit,
				store : store,
				emptyMsg : "<font color='red'>没有记录</font>",
				displayInfo : true,
				plugins:new Ext.ux.ComboPageSize({addToItem:true,index:10})
			}),
			tbar:[{text:'添加',iconCls:'add',handler:function(){showAddOrUpdate('add');}},
				' ',{text:'修改',iconCls:'update', handler:function(){showAddOrUpdate('update');}},
				' ',{text:'删除',iconCls:'delete',handler:doDelete},
				'->',{
					xtype:'combo',
					id:'searchCombo',
					typeAhead: true,
				    triggerAction: 'all',
				    lazyRender:true,
				    mode: 'local',
				    value:'选择查询内容',
				    width:80,
				    editable:false,
				    store: new Ext.data.ArrayStore({
				        fields: ['keytype','keytext'],
				        data: [['week1', '孕周段1'], ['week2', '孕周段2'], ['content', '指导内容']]
				    }),
				    valueField: 'keytype',
				    displayField: 'keytext'
				},' ',{xtype:'textfield',emptyText:'输入关键字查找',enableKeyEvents:true,id:'searchText',width:180,
					listeners:{
						keydown:{
							fn:function(t,e){
								if(e.keyCode == 13){
									search();
								}
							},
							buffer:350,
							scope:this
						}
					}
			},' ',
			{text:'查&nbsp;&nbsp;询',iconCls:'query',handler:search},'-',
			{text:'刷&nbsp;&nbsp;新',iconCls:'refresh',handler:function(){
				Ext.getCmp('searchCombo').setValue("week1");
				Ext.getCmp('searchText').setValue("");
				Ext.apply(store.baseParams,{field:'',keyword:''});
				store.load();
			}}]
			
		}),
		tab = curPanel.add({
			title : '&nbsp;高危孕产妇&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;',
			id : tabId,
			closable : true,
			layout : 'card',
			iconCls:'userSuit',
			activeItem :0,
			listeners:{
				activate:function(p){
					store.load();
				}
			},
			items:[grid]
		});	
		curPanel.setActiveTab(tab);
	}
	
	/** 添加或者修改 **/
	function showAddOrUpdate(type){
		
		var store = new Ext.data.Store({
			autoLoad:false,
			proxy:new Ext.data.HttpProxy({url:App.baseURL+'/eduHighRiskGravida/findPage'}),
			reader:new Ext.data.JsonReader({
				totalProperty:'totalCount',
				root:'datas',
				idProperty:'id',
				fields:[{name:'id'},{name:'week1'},{name:'week2'},{name:'content'},{name:'statue'},{name:'highRiskName'}]
			}),
			baseParams:{start:0,limit:limit,field:'',keyword:''},
			listeners:{