关于EXTJS PagingToolbar分页的问题

良才2015 2011-11-10 02:46:12
可以查询出第一次分页的结果,并展示到前台,但是相关信息并没有关联上,如第{0} 到 {1} 条数据 共{2}条显示不了。只显示“没有数据”。
前台代码如下:
	//初始化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}});

后台代码如下:
			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数据格式如下:
{"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……]}

[img=[URL=http://www.ouliu.net][IMG]http://www.ouliu.net/j/84bcb456747c9d14b9fc64c7ca730fa1.png[/IMG][/URL]][/img]
...全文
178 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
良才2015 2011-11-10
  • 打赏
  • 举报
回复
不能沉下去
javascript_2011 2011-11-10
  • 打赏
  • 举报
回复
//displayMsg: '第{0} 到 {1} 条数据 共{2}条',
注释掉试试
qiubin200236 2011-11-10
  • 打赏
  • 举报
回复
json我一直没有成功过,后来改为xml了

js

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;
}
}


});


XML如下
<?xml version='1.0' encoding='utf-8' ?>
<nodes>
<TotalRecord>1</TotalRecord>
<node>
<code>001</code>
<name>aaa</name>
<price>10</price>
</node>
</nodes>

qiubin200236 2011-11-10
  • 打赏
  • 举报
回复
json我一直没有成功过,后来改为xml了

js

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;
}
}


});


XML如下
<?xml version='1.0' encoding='utf-8' ?>
<nodes>
<TotalRecord>1</TotalRecord>
<node>
<code>001</code>
<name>aaa</name>
<price>10</price>
</node>
</nodes>

良才2015 2011-11-10
  • 打赏
  • 举报
回复
不能沉下去
良才2015 2011-11-10
  • 打赏
  • 举报
回复
不能沉下去
良才2015 2011-11-10
  • 打赏
  • 举报
回复
图片挂了,重发下

52,798

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 Ajax
社区管理员
  • Ajax
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧