ストアにページサイズを設定し、プロキシ設定に totalproperty を設定し、dockedItems 構成も定義しました。ただし、ページでは、指定されたページサイズではなく、すべてのレコードが表示されます。これが私のコードです:
js ファイル:
var sm = Ext.create('Ext.selection.CheckboxModel');
Ext.define('SuperUser', {
extend: 'Ext.data.Model',
fields: [
{ name: 'fname', type: 'string' },
{ name: 'lname', type: 'string' },
{ name: 'email', type: 'string' },
{ name: 'uid', type: 'string' },
{ name: 'isSup', type: 'boolean' },
{ name: 'upDate', type: 'string' },
{ name: 'upBy', type: 'string' }
]
});
//Create the grid
var superGrid=Ext.define('supusergrid', {
extend: 'Ext.grid.Panel',
alias: 'widget.supusergrid',
title: 'Super Admin Grid',
gridId:'grid',
model:'SuperUser',
store: Ext.create('Ext.data.Store', {
storeId: 'supUserStore',
pageSize: 3,
model:'SuperUser',
autoLoad: true,
proxy: {
type: 'ajax',
url : 'supUserStore.json',
reader: {
type: 'json',
root: 'data',
totalProperty:'total'
}
}
}),
selModel: sm,
columns: [
{
header: 'First Name',
dataIndex: 'fname'
},
{
header: 'Last Name',
dataIndex: 'lname'
},
{
header: 'Email',
dataIndex: 'email'
},
{
header: 'User ID',
dataIndex: 'uid'
},
{
header: 'Super Admin',
dataIndex: 'isSup'
},
{
header: 'Updated Date',
dataIndex: 'upDate',
},
{
header: 'Updated By',
dataIndex: 'upBy'
}
],
dockedItems: [{
xtype: 'pagingtoolbar',
store: Ext.data.StoreManager.lookup('supUserStore'),
dock: 'bottom',
displayInfo: true
}],
initComponent: function () {
this.callParent(arguments);
}
});
Ext.onReady(function () {
Ext.widget('supusergrid', {
renderTo: 'div1'
});
});
json ファイル:
{
"success": true,
"total": 12,
"data": [
{ "fname": "Jane","lname":"Smith","email": "j.smith@netapp.com", "uid": "jsmith","isSup":false,"upDate":"11-19-2012","upBy":"aaron@netapp.com" },
{ "fname": "Jim","lname":"Smith","email": "jm.smith@netapp.com", "uid": "jmsmith","isSup":true,"upDate":"11-23-2012","upBy":"aaron@netapp.com" },
{ "fname": "Jane","lname":"Smith","email": "j.smith@netapp.com", "uid": "jsmith","isSup":false,"upDate":"11-19-2012","upBy":"aaron@netapp.com" },
{ "fname": "Jim","lname":"Smith","email": "jm.smith@netapp.com", "uid": "jmsmith","isSup":true,"upDate":"11-23-2012","upBy":"aaron@netapp.com" },
{ "fname": "Jane","lname":"Smith","email": "j.smith@netapp.com", "uid": "jsmith","isSup":false,"upDate":"11-19-2012","upBy":"aaron@netapp.com" },
{ "fname": "Jim","lname":"Smith","email": "jm.smith@netapp.com", "uid": "jmsmith","isSup":true,"upDate":"11-23-2012","upBy":"aaron@netapp.com" },
{ "fname": "Jane","lname":"Smith","email": "j.smith@netapp.com", "uid": "jsmith","isSup":false,"upDate":"11-19-2012","upBy":"aaron@netapp.com" },
{ "fname": "Jim","lname":"Smith","email": "jm.smith@netapp.com", "uid": "jmsmith","isSup":true,"upDate":"11-23-2012","upBy":"aaron@netapp.com" },
{ "fname": "Jane","lname":"Smith","email": "j.smith@netapp.com", "uid": "jsmith","isSup":false,"upDate":"11-19-2012","upBy":"aaron@netapp.com" },
{ "fname": "Jim","lname":"Smith","email": "jm.smith@netapp.com", "uid": "jmsmith","isSup":true,"upDate":"11-23-2012","upBy":"aaron@netapp.com"}
]
}
私が間違っているところを提案してください。