日期:2014-05-16 浏览次数:20321 次
JSONObject json = new JSONObject(); json.put("result", list); json.put("totalCount", list.size()); System.out.println("-------------="+json.toString()); HttpServletResponse response = ServletActionContext.getResponse(); // 编制响应的格式 response.setContentType("text/html;charset=UTF-8"); try { response.getWriter().write(json.toString()); } catch (IOException e) { e.printStackTrace(); } return null;
ListGridPanel=function(viewer,config){ Ext.apply(this,viewer); this.init(config); ListGridPanel.superclass.constructor.call(this,{ }); }; Ext.extend(ListGridPanel,Ext.grid.GridPanel,{ init:function(config){ var col=[]; var rcol=[]; for(var i=0,j=config.columns;i<j.length;i++){ if(j[i]["dataIndex"]!=""){ col.push(j[i]); rcol.push({name:j[i]["dataIndex"]}); } } this.columns=col; alert("我来了数据="+config.url); var store = new Ext.data.Store({ url:config.url, baseParams:{method:config.method,limit:10,start:0}, reader:new Ext.data.JsonReader({totalProperty: 'totalCount',root:"result"},Ext.data.Record.create(rcol)), autoLoad:true }); this.store = store, this.region='center', this.loadMask=true, this.bbar= new Ext.PagingToolbar({store:store,pageSize:10,displayMsg:'显示第 {0} 条到 {1} 条记录,一共 {2} 条', emptyMsg:'没有记录'}); } }); 自己的jsp: var usercheckbox =new Ext.grid.CheckboxSelectionModel(); var userrownumber=new Ext.grid.RowNumberer(); var widthValue=61; var yoyo = "123"; //权限表头 var purview=[usercheckbox,userrownumber, {header:'应用提供商编号',dataIndex:'bpid',sortable:true}, {header:'服务名称',dataIndex:'bsName',sortable:true}, {header:'密码',dataIndex:'password',sortable:true}, {header:'用系统名称',dataIndex:'userName',sortable:true} ]; var config={columns:purview,url:'<%=basePath%>/AdminLogin/login/adminLoginAction_loginQueryUserList',method:'loginQueryUserList'}; var gridpanel=new ListGridPanel({height:500,width:1200,sm:usercheckbox,id:"grid"},config); 记得: <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> <script type="text/javascript" src="<%=basePath%>/AdminLogin/common/ext/ext-base.js"></script> <script type="text/javascript" src="<%=basePath%>/AdminLogin/common/ext/ext-all.js"></script> <link rel="stylesheet" type="text/css" href="<%=basePath%>/AdminLogin/common/ext/resources/css/ext-all.css" /> <script type="text/javascript" src="<%=basePath%>/AdminLogin/common/myGrid.js"></script> <script type="text/javascript"