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

关于EXTJS PagingToolbar分页的问题 - Web 开发 / Ajax
可以查询出第一次分页的结果,并展示到前台,但是相关信息并没有关联上,如第{0} 到 {1} 条数据 共{2}条显示不了。只显示“没有数据”。
前台代码如下:
JScript code
    //初始化grid 
    var grid = null; 
    //查询信息 
    var store = new Ext.data.Store({ 
    //proxy: new Ext.data.HttpProxy({url:'../system/sysparamList!query.icode?flag=extjs&recordCount=<s:property value="pageAttribute.recordCount"/>&pageCount=<s:property value="pageAttribute.pageCount"/>&pageNo=<s:property value="pageAttribute.pageNo"/>&maxResults=<s:property value="pageAttribute.maxResults"/>&startPosition=<s:property value="pageAttribute.startPosition"/>'}),
    proxy: new Ext.data.HttpProxy({url:'../system/sysparamList!query.icode'}),
    reader:new Ext.data.JsonReader({ 
        root:'jsonarray',
        totalProperty:'totalCount',
        id:'paramid'
            }, 
        storeRecord),
    method:'post'
    }); 

    grid = new Ext.grid.GridPanel({ 
    renderTo:"mainDiv", //grid查询结果指向显示的div层 
    title:"用户查询结果", //grid标题 
    autoHeight : true,
    cm:colM, //定义的列 
    store:store, //定义的数据源 
    bbar: new Ext.PagingToolbar({   
                        pageSize: 20,   
                        store: store,   
                        params : {
                            start : 'start',
                            limit : 'limit'
                            },
                        displayInfo: true,   
                        displayMsg: '第{0} 到 {1} 条数据 共{2}条',   
                        emptyMsg: "没有数据"   
                   })   
             
    }); 

    store.load({params:{start:0, limit:20}});   


后台代码如下:
Java code
            db = new DBOperation();
            dao = new SysparamDAO(db);
            sysparamList = doQuery();

            
            
            
            
            response.setHeader("Cache-Control", "no-cache");
            response.setContentType("text/json;charset=UTF-8");
            JSONArray json = JSONArray.fromObject(sysparamList);
            String jsonarray = json.toString();
            jsonarray = "{\"totalCount\":\"" + sysparamList.size()+ "\",\"jsonarray\":" + jsonarray + "}";
            System.out.println(jsonarray);
            response.getWriter().write(jsonarray);


json数据格式如下:
JScript code
{"totalCount":"20","jsonarray":[{"data":"","fmt":"","gcode":"TRVL_DORM","id":469,"mcode":"0","mname":"酒店","scope":0,"sort":0},{"data":"","fmt":"","gcode":"TRVL_TRAFFIC","id":472,"mcode":"0","mname":"飞机","scope":0,"sort":0},{"data":"","fmt":"","gcode":"PRV_MARRY","id":289,"mcode":"0","mname":"未婚","scope":0,"sort":0},xxx,xxx,xxx……]}


[/URL]][/img]

------解决方案--------------------
json我一直没有成功过,后来改为xml了

js
JScript code

        store_ElectriPrice = Ext.create('Ext.data.Store',{
            pageSize: 20,
            model: 'ElectriPrice',
            autoLoad: true,
            proxy: {