AJax技术

关于EXTJS PagingToolbar分页的有关问题

字号+ 作者:H5之家 来源:H5之家 2017-11-26 15:11 我要评论( )

关于EXTJS PagingToolbar分页的问题 - Web 开发 / Ajax可以查询出第一次分页的结果,并展示到前台,但是相关信息并没有关联上,如第{0} 到 {1} 条数据 共{2}条显

关于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; } } });

 

1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

相关文章
  • 自己写的Asp.netAjax,Jquery,ExtJs三种Ajax技术框架比较,希望大家提提意见,谢谢。-.NET技术

    自己写的Asp.netAjax,Jquery,ExtJs三种Ajax技术框架比较,希望大家提

    2017-11-10 09:03

  • 关于面试遇到的一些问题的记录

    关于面试遇到的一些问题的记录

    2017-10-27 13:01

  • 标签:[ ajaxajax ] 列表

    标签:[ ajaxajax ] 列表

    2017-10-17 10:29

  • 关于AJAX跨域调用ASP.NET MVC或者WebAPI服务的问题及解决方案

    关于AJAX跨域调用ASP.NET MVC或者WebAPI服务的问题及解决方案

    2017-10-10 13:06

网友点评