使用分页工具栏的 ExtJS 网格面板
我正在尝试使用分页工具栏制作 ext JS 网格面板,但无法弄清楚问题出在哪里。谁能帮我解决这个问题-
var myData = {
record : [
{ name : "Record 0", column1 : "0", column2 : "0" },
{ name : "Record 1", column1 : "1", column2 : "1" },
{ name : "Record 2", column1 : "2", column2 : "2" },
]
};
var fields = [
{name: 'name', mapping : 'name'},
{name: 'column1', mapping : 'column1'},
{name: 'column2', mapping : 'column2'}
];
var store = new Ext.data.Store ({
id :'simpsonsStore',
fields:['name', 'column1', 'column2'],
pageSize: 5,
data: myData,
reader: {
root: 'record',
type: 'json'
}
});
// Column Model shortcut array
var cols = [
{ id : 'name', header: "Record Name", width: 50, sortable: true, dataIndex: 'name'},
{header: "column1", width: 50, sortable: true, dataIndex: 'column1'},
{header: "column2", width: 50, sortable: true, dataIndex: 'column2'}
];
store.load({
params:{
start:0,
limit: 5
}
});
// declare the source Grid
var grid = new Ext.grid.GridPanel({
ddGroup : 'gridDDGroup',
store : store,
columns : cols,
enableDragDrop : true,
stripeRows : true,
autoExpandColumn : 'name',
width : 650,
height : 325,
region : 'west',
title : 'Data Grid',
selModel : new Ext.grid.RowSelectionModel({singleSelect : true}),
dockedItems: [{
xtype: 'pagingtoolbar',
store: store, // same store GridPanel is using
dock: 'bottom',
displayInfo: true
}]
});
var displayPanel = new Ext.Panel({
width : 650,
height : 300,
layout : 'column',
renderTo : Ext.getBody(),
items : [
grid
],
bbar : [
'->',
{
text : 'Reset Example',
handler : function() {
gridStore.loadData(myData);
}
}
]
});
I am trying to make ext JS grid panel using Paging Toolbar but not able to figure out where the problem is coming. Can anyone help me out in this-
var myData = {
record : [
{ name : "Record 0", column1 : "0", column2 : "0" },
{ name : "Record 1", column1 : "1", column2 : "1" },
{ name : "Record 2", column1 : "2", column2 : "2" },
]
};
var fields = [
{name: 'name', mapping : 'name'},
{name: 'column1', mapping : 'column1'},
{name: 'column2', mapping : 'column2'}
];
var store = new Ext.data.Store ({
id :'simpsonsStore',
fields:['name', 'column1', 'column2'],
pageSize: 5,
data: myData,
reader: {
root: 'record',
type: 'json'
}
});
// Column Model shortcut array
var cols = [
{ id : 'name', header: "Record Name", width: 50, sortable: true, dataIndex: 'name'},
{header: "column1", width: 50, sortable: true, dataIndex: 'column1'},
{header: "column2", width: 50, sortable: true, dataIndex: 'column2'}
];
store.load({
params:{
start:0,
limit: 5
}
});
// declare the source Grid
var grid = new Ext.grid.GridPanel({
ddGroup : 'gridDDGroup',
store : store,
columns : cols,
enableDragDrop : true,
stripeRows : true,
autoExpandColumn : 'name',
width : 650,
height : 325,
region : 'west',
title : 'Data Grid',
selModel : new Ext.grid.RowSelectionModel({singleSelect : true}),
dockedItems: [{
xtype: 'pagingtoolbar',
store: store, // same store GridPanel is using
dock: 'bottom',
displayInfo: true
}]
});
var displayPanel = new Ext.Panel({
width : 650,
height : 300,
layout : 'column',
renderTo : Ext.getBody(),
items : [
grid
],
bbar : [
'->',
{
text : 'Reset Example',
handler : function() {
gridStore.loadData(myData);
}
}
]
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在
displayPanel
的 bbar 中,处理程序正在对gridStore
变量调用loadData
,该变量未在您发布的代码片段中定义。我想您需要对此处声明的存储变量调用
loadData
:您还可以调用
grid.getStore().loadData();
In the
displayPanel
's bbar, handler is callingloadData
, on thegridStore
variable which is not defined in the code snippet you've posted.I guess you need to call
loadData
on the store variable declared here:You could also call
grid.getStore().loadData();