Javascript 使用本地数据的Ext js分页不起作用
我尝试使用ExtJs4网格启用分页。分页工具栏看起来正在工作,但网格中没有启用分页功能。您能帮我解决我缺少的问题吗Javascript 使用本地数据的Ext js分页不起作用,javascript,extjs,extjs4.2,pagingtoolbar,Javascript,Extjs,Extjs4.2,Pagingtoolbar,我尝试使用ExtJs4网格启用分页。分页工具栏看起来正在工作,但网格中没有启用分页功能。您能帮我解决我缺少的问题吗 Ext.onReady(function () { var i = 1; Ext.define('User', { extend: 'Ext.data.Model', fields: [ { name: 'id', type: 'int' }, { name: 'first
Ext.onReady(function () {
var i = 1;
Ext.define('User', {
extend: 'Ext.data.Model',
fields: [
{ name: 'id', type: 'int' },
{ name: 'firstName', type: 'string' },
{ name: 'lastName', type: 'string' },
{ name: 'age', type: 'int' },
{ name: 'eyeColor', type: 'string' }
]
});
看起来问题出在totalCount上,但还有更多的问题
var store= Ext.create('Ext.data.Store', {
model: 'User',
totalCount:50,
pageSize: 10,
autoLoad: { start: 0, limit: 10 },
proxy: {
type: 'memory',
reader: {
root: 'users',
totalProperty: 'totalCount'
}
},
data: [
{ id: i++, firstName: 'Ed', lastName: 'Spencer', age:20, eyeColor: 'blue' },
{ id: i++, firstName: 'Tommy', lastName: 'Maintz', age: 30, eyeColor: 'black' },
{ id: i++, firstName: 'Aaron', lastName: 'Conran', age: 40, eyeColor: 'blue' },
{ id: i++, firstName: 'Jamie', lastName: 'Avins', age: 50, eyeColor: 'black' },
{ id: i++, firstName: 'Ed', lastName: 'Spencer', age: 20, eyeColor: 'blue' }
.
.
.
]
});
分页工具栏看起来正在工作,但网格值不会根据页码变化
Ext.create('Ext.grid.Panel', {
title: 'Users',
store: store,
proxy: {
type: 'memory',
enablePaging: true
},
columns: [
{ header: 'ID', dataIndex: 'id', width:50 },
{ header: 'Name', dataIndex: 'firstName' },
{ header: 'Last Name', dataIndex: 'lastName' },
{ header: 'Age', dataIndex: 'age', width: 50 },
{ header: 'Eye Color', dataIndex: 'eyeColor' }
],
height: 600,
width: 800,
dockedItems: [{
xtype: 'pagingtoolbar',
store: store,
pageSize: 10,
dock: 'bottom',
displayInfo: true
}],
renderTo: Ext.getBody()
});
});
您需要
代理:'pagingmemory'
,它是
发件人:
使用本地数据分页
也可以使用扩展名使用本地数据完成分页:
- Ext.ux.data.PagingStore
- 分页内存代理(示例/ux/PagingMemoryProxy.js)
存储配置中(将由代理提供)李>totalCount
在网格上(它已经在商店中)李>proxy
- 页面工具栏配置中的
(将从存储中获取)pageSize