读书人

关于EXTJS PagingToolbar分页的有关问

发布时间: 2012-03-11 18:15:38 作者: rapoo

关于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: {                type: 'ajax',                url: '/ajax/manage-get_electri_price_xml',                reader: {                    type: 'xml',                    record: 'node',                    idProperty: 'code',                    totalProperty: 'TotalRecord'                }            },            remoteSort: true        });        grid_ElectriPrice = Ext.create('Ext.grid.Panel', {            height: "100%",            store: store_ElectriPrice,            columns: [            { text: "编号", width: 180, dataIndex: 'code', sortable: true },            { text: "名称", width: 180, dataIndex: 'name', sortable: true },            { text: "价格", width: 115, dataIndex: 'price', sortable: true}        ], tbar: {            xtype: 'toolbar',            enableOverflow: true,            items: [{                xtype: 'tbtext',                text: '电价管理'            },            '->',            {                iconCls: 'icon-add',                text: '添加',                scope: this,                handler: onAddClick_ElectriPrice            }, {                iconCls: 'icon-edit',                text: '编辑',                scope: this,                handler: onEditClick_ElectriPrice            }, {                iconCls: 'icon-delete',                text: '删除',                scope: this,                handler: onDeleteClick_ElectriPrice            }]        },            bbar: {                xtype: 'pagingtoolbar',                store: store_ElectriPrice,                displayInfo: true,                listeners: {                    change: function (PagingToolbar, pageData) {                        obj_ElectriPrice = null;                    }                }            },            viewConfig: {                listeners: {                    itemclick: function (DataView, record, item, index, e) {                        obj_ElectriPrice = record;                    },                    itemdblclick: function (DataView, record, item, index, e) {                        onEditClick_ElectriPrice()                    }                }            }, listeners: {                destroy: function (Component) {                    grid_ElectriPrice = null;                }            }        }); 


[解决办法]
json我一直没有成功过,后来改为xml了

js

JScript code
        store_ElectriPrice = Ext.create('Ext.data.Store',{            pageSize: 20,            model: 'ElectriPrice',            autoLoad: true,            proxy: {                type: 'ajax',                url: '/ajax/manage-get_electri_price_xml',                reader: {                    type: 'xml',                    record: 'node',                    idProperty: 'code',                    totalProperty: 'TotalRecord'                }            },            remoteSort: true        });        grid_ElectriPrice = Ext.create('Ext.grid.Panel', {            height: "100%",            store: store_ElectriPrice,            columns: [            { text: "编号", width: 180, dataIndex: 'code', sortable: true },            { text: "名称", width: 180, dataIndex: 'name', sortable: true },            { text: "价格", width: 115, dataIndex: 'price', sortable: true}        ], tbar: {            xtype: 'toolbar',            enableOverflow: true,            items: [{                xtype: 'tbtext',                text: '电价管理'            },            '->',            {                iconCls: 'icon-add',                text: '添加',                scope: this,                handler: onAddClick_ElectriPrice            }, {                iconCls: 'icon-edit',                text: '编辑',                scope: this,                handler: onEditClick_ElectriPrice            }, {                iconCls: 'icon-delete',                text: '删除',                scope: this,                handler: onDeleteClick_ElectriPrice            }]        },            bbar: {                xtype: 'pagingtoolbar',                store: store_ElectriPrice,                displayInfo: true,                listeners: {                    change: function (PagingToolbar, pageData) {                        obj_ElectriPrice = null;                    }                }            },            viewConfig: {                listeners: {                    itemclick: function (DataView, record, item, index, e) {                        obj_ElectriPrice = record;                    },                    itemdblclick: function (DataView, record, item, index, e) {                        onEditClick_ElectriPrice()                    }                }            }, listeners: {                destroy: function (Component) {                    grid_ElectriPrice = null;                }            }        });
[解决办法]
//displayMsg: '第{0} 到 {1} 条数据 共{2}条',
注释掉试试

读书人网 >Ajax

热点推荐