我的json数据是这样的,是固定的不用读取数据库的,也就是说没有start limit参数,怎样使用extjs grid分页显示???在线等、新人求教!
{"articleList":[{"articleId":1,"title":"1","author":"heshan","hits":"0","addDate":"2011-06-11 13:33:23"},{"articleId":2,"title":"2","author":"superman","hits":"0","addDate":"2011-06-11 13:35:18"},{"articleId":3,"title":"3","author":"superman","hits":"0","addDate":"2011-06-11 13:51:31"},{"articleId":4,"title":"4","author":"superman","hits":"0","addDate":"2011-06-11 13:55:54"},{"articleId":5,"title":"5","author":"superman","hits":"0","addDate":"2011-06-11 13:56:29"},{"articleId":6,"title":"拜拜拜拜吧","author":"superman","hits":"0","addDate":"2011-06-11 14:51:51"},{"articleId":7,"title":"333","author":"superman","hits":"0","addDate":"2011-06-11 15:00:56"},]}
{"articleList":[{"articleId":1,"title":"1","author":"heshan","hits":"0","addDate":"2011-06-11 13:33:23"},{"articleId":2,"title":"2","author":"superman","hits":"0","addDate":"2011-06-11 13:35:18"},{"articleId":3,"title":"3","author":"superman","hits":"0","addDate":"2011-06-11 13:51:31"},{"articleId":4,"title":"4","author":"superman","hits":"0","addDate":"2011-06-11 13:55:54"},{"articleId":5,"title":"5","author":"superman","hits":"0","addDate":"2011-06-11 13:56:29"},{"articleId":6,"title":"拜拜拜拜吧","author":"superman","hits":"0","addDate":"2011-06-11 14:51:51"},{"articleId":7,"title":"333","author":"superman","hits":"0","addDate":"2011-06-11 15:00:56"},]}
id:'simpsonsStore',
autoLoad: false,
fields:['name', 'email', 'phone'],
pageSize: itemsPerPage, // items per page
proxy: {
type: 'ajax',
url: 'pagingstore.js', // url that will load data with respect to start and limit params
reader: {
type: 'json',
root: 'items',
totalProperty: 'total'
}
}
});// specify segment of data you want to load using params
store.load({
params:{
start:0,
limit: itemsPerPage
}
});Ext.create('Ext.grid.Panel', {
title: 'Simpsons',
store: store,
columns: [
{header: 'Name', dataIndex: 'name'},
{header: 'Email', dataIndex: 'email', flex:1},
{header: 'Phone', dataIndex: 'phone'}
],
width: 400,
height: 125,
dockedItems: [{
xtype: 'pagingtoolbar',
store: store, // same store GridPanel is using
dock: 'bottom',
displayInfo: true
}],
renderTo: Ext.getBody()
});
用json数据只要root=articleList
你贴出的json似乎末尾多了个","。
以下仅供参考:
reader: new Ext.data.JsonReader({
root: 'articleList',
totalProperty: 'totalCount',
fields: [
{name: 'replycount'},
{name: 'lastpost'}
]
})JSON可以这样对应,增加totalCount,表示总条数。
{"totalCount":"1000","articleList":[{"articleId":1,"title":"1","author":"heshan","hits":"0","addDate":"2011-06-11 13:33:23"},{"articleId":2,"title":"2","author":"superman","hits":"0","addDate":"2011-06-11 13:35:18"},{"articleId":3,"title":"3","author":"superman","hits":"0","addDate":"2011-06-11 13:51:31"},{"articleId":4,"title":"4","author":"superman","hits":"0","addDate":"2011-06-11 13:55:54"},{"articleId":5,"title":"5","author":"superman","hits":"0","addDate":"2011-06-11 13:56:29"},{"articleId":6,"title":"拜拜拜拜吧","author":"superman","hits":"0","addDate":"2011-06-11 14:51:51"},{"articleId":7,"title":"333","author":"superman","hits":"0","addDate":"2011-06-11 15:00:56"}]}
http://topic.csdn.net/u/20110608/16/41a93a68-4fd8-46c0-af3d-3c472f87ec6e.html