ExtJS 网格面板分页工具栏未显示每页所需的记录数
我是 extJS 的新手,我试图在网格面板中显示 8[随机数] 条记录,并且还使用分页工具栏每页显示 4 条记录,但它仅在一页中显示 8 条记录。
var myData = [
['3m Co', 71.72, 0.02, 0.03, '9/1 12:00am'],
['Alcoa Inc', 29.01, 0.42, 1.47, '9/1 12:00am'],
['American International Group, Inc.', 64.13, 0.31, 0.49, '9/1 12:00am'],
['AT&T Inc.', 31.61, -0.48, -1.54, '9/1 12:00am'],
['Boeing Co.', 75.43, 0.53, 0.71, '9/1 12:00am'],
['Caterpillar Inc.', 67.27, 0.92, 1.39, '9/1 12:00am'],
['Citigroup, Inc.', 49.37, 0.02, 0.04, '9/1 12:00am'],
['Wal-Mart Stores, Inc.', 45.45, 0.73, 1.63, '9/1 12:00am']
];
var store = new Ext.data.ArrayStore({
totalProperty: 8,
autoLoad: {
params: {
start: 0,
limit: 4
}
},
fields: [{
name: 'company'
}, {
name: 'price',
type: 'float'
}, {
name: 'change',
type: 'float'
}, {
name: 'pctChange',
type: 'float'
}, {
name: 'lastChange',
type: 'date',
dateFormat: 'n/j h:ia'
}]
});
store.loadData(myData);
var grid = new Ext.grid.GridPanel({
store: store,
columns: [{
id: 'company',
header: "Company",
width: 160,
sortable: true,
dataIndex: 'company'
}, {
header: "Price",
width: 75,
sortable: true,
renderer: 'usMoney',
dataIndex: 'price'
}, {
header: "Change",
width: 75,
sortable: true,
renderer: change,
dataIndex: 'change'
}, {
header: "% Change",
width: 75,
sortable: true,
renderer: pctChange,
dataIndex: 'pctChange'
}, {
header: "Last Updated",
width: 85,
sortable: true,
renderer: Ext.util.Format.dateRenderer('m/d/Y'),
dataIndex: 'lastChange'
}],
stripeRows: true,
autoExpandColumn: 'company',
height: 350,
width: 600,
title: 'Array Grid',
bbar: new Ext.PagingToolbar({
store: store,
pageSize: 4,
displayInfo: true
}),
viewConfig: {
forceFit: true
}
});
谁能告诉我如何解决这个问题?
I am new to extJS and I am trying to show 8[a random number] records in a grid panel and am also using paging toolbar to show 4 records per page but it shows 8 records in one page only.
var myData = [
['3m Co', 71.72, 0.02, 0.03, '9/1 12:00am'],
['Alcoa Inc', 29.01, 0.42, 1.47, '9/1 12:00am'],
['American International Group, Inc.', 64.13, 0.31, 0.49, '9/1 12:00am'],
['AT&T Inc.', 31.61, -0.48, -1.54, '9/1 12:00am'],
['Boeing Co.', 75.43, 0.53, 0.71, '9/1 12:00am'],
['Caterpillar Inc.', 67.27, 0.92, 1.39, '9/1 12:00am'],
['Citigroup, Inc.', 49.37, 0.02, 0.04, '9/1 12:00am'],
['Wal-Mart Stores, Inc.', 45.45, 0.73, 1.63, '9/1 12:00am']
];
var store = new Ext.data.ArrayStore({
totalProperty: 8,
autoLoad: {
params: {
start: 0,
limit: 4
}
},
fields: [{
name: 'company'
}, {
name: 'price',
type: 'float'
}, {
name: 'change',
type: 'float'
}, {
name: 'pctChange',
type: 'float'
}, {
name: 'lastChange',
type: 'date',
dateFormat: 'n/j h:ia'
}]
});
store.loadData(myData);
var grid = new Ext.grid.GridPanel({
store: store,
columns: [{
id: 'company',
header: "Company",
width: 160,
sortable: true,
dataIndex: 'company'
}, {
header: "Price",
width: 75,
sortable: true,
renderer: 'usMoney',
dataIndex: 'price'
}, {
header: "Change",
width: 75,
sortable: true,
renderer: change,
dataIndex: 'change'
}, {
header: "% Change",
width: 75,
sortable: true,
renderer: pctChange,
dataIndex: 'pctChange'
}, {
header: "Last Updated",
width: 85,
sortable: true,
renderer: Ext.util.Format.dateRenderer('m/d/Y'),
dataIndex: 'lastChange'
}],
stripeRows: true,
autoExpandColumn: 'company',
height: 350,
width: 600,
title: 'Array Grid',
bbar: new Ext.PagingToolbar({
store: store,
pageSize: 4,
displayInfo: true
}),
viewConfig: {
forceFit: true
}
});
Can anyone tell me how can I solve this problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用
Ext.ux.data.PagingStore
进行客户端分页。尝试这样的事情:
您可能需要稍微调整一下,因为我还没有测试过它。
我让它与从服务器获取记录的 JsonReader 一起使用。
希望这有帮助。
You can use the
Ext.ux.data.PagingStore
for client side paging.Try something like this:
You may need to tweak this a bit as I have not tested it.
I have it working with a
JsonReader
fetching records from the server.Hope this helps.
您应该在存储上调用 .load() 函数,并传入一个带有指定最大页面大小的参数的对象,而不是使用 store.loadData() 调用。
查看此页面上的示例 http://dev .sencha.com/deploy/ext-3.3.1/docs/?class=Ext.PagingToolbar
编辑:另一种选择是执行以下操作。调用 .loadData(),实例化网格后,您可以调用
instead of using the store.loadData() call you should be calling the .load() function on the store and passing in an object with arguments specifying your maximum page size.
check out the examples on this page http://dev.sencha.com/deploy/ext-3.3.1/docs/?class=Ext.PagingToolbar
EDIT: Another option is to do the following. Call the .loadData() and after you have instantiated your grid, you can call