DWR+EXTJS 加载GRID数据

1、使用插件

     DWRProxy.js

2、JS代码

    

var store=new Ext.data.Store({
			proxy:new Ext.data.DWRProxy(EmployeeService.findEmployeeRange,true),
			reader : new Ext.data.ListRangeReader ({
				 totalProperty:'totalSize',
				root:"data"
			}, record)
		})

  

var record=new Ext.data.Record.create([{
			name:"EMP_ID"
		},{
			name:"EMP_NAME"
		},{
			name:"EMP_SEX"
		}])

 

var cm=new Ext.grid.ColumnModel([{
			header:"员工编号",
			dataIndex:"EMP_ID"
		},{
			header:"员工姓名",
			dataIndex:"EMP_NAME"
		},{
			header:"员工性别",
			dataIndex:"EMP_SEX",
			renderer:function(val){
				if(val=="1"){
					return "<span style='color:green;font-weight:bold;'>男</span>"
				}else{
					return "<span style='color:red;font-weight:bold;'>女</span>"
				}
			}
			
		}])

 

var gridPanel=new Ext.grid.GridPanel({
			region:"center",
			title:"查询结果",
			tbar:tb,
			loadMask:{
				msg:"正在加载数据..."
			},
			viewConfig:{
				getRowClass:function(record,rowIndex,rowParams,store){
					if(rowIndex%2==0){
						 return 'my_row_Red'; 
					}else{
						 return 'my_row_Gray'; 
					}
				}
			},
			stripeRows:true,
			cm:cm,
			store:store,
			bbar:pageBar
		})

 

store.on('beforeload', function() {
	store.baseParams = {
		device_type : ""
	};

});
store.load({
	params : {
		device_type : ""
	}
});

 

你可能感兴趣的:(DWR,ExtJs,grid,DWRPROXY)