抱歉,我认为这可能是重复的。但我没有从任何地方得到正确的答案。请帮我找出问题所在。
我正在创建一个带有商店的 Ext Js 网格。还借助此博客 http://blog.jardalu.com/2013/6/21/grid-paging-extjs-sencha
我正在创建为第一个页面加载数据页面的网格。但是当我按下下一个,最后,刷新没有任何事件在起作用。同样从控制台我从 ext js 文件中收到这样的错误
Uncaught TypeError: Cannot read property 'name' of undefined
请帮我找出问题所在。
代码:-
/*global Ext:false */
Ext.require([
'Ext.data.*',
'Ext.grid.*'
]);
Ext.onReady(function () {
var itemsPerPage = 2; // set the number of items you want per page
var store = Ext.create('Ext.data.Store', {
id: 'simpsonsStore',
autoLoad: false,
fields: ['name', 'email', 'phone'],
pageSize: itemsPerPage,
data: {
'items': [{
'name': 'Lisa',
"email": "lisa@simpsons.com",
"phone": "555-111-1224"
}, {
'name': 'Bart',
"email": "bart@simpsons.com",
"phone": "555-222-1234"
}, {
'name': 'Homer',
"email": "home@simpsons.com",
"phone": "555-222-1244"
}, {
'name': 'Marge',
"email": "marge@simpsons.com",
"phone": "555-222-1254"
}]
},
proxy: {
type: 'memory',
reader: {
type: 'json',
root: 'items',
totalProperty: 'total'
}
},
listeners : {
beforeload : function(store, operation, eOpts){
var page = operation.page;
var limit = operation.limit;
var dataResult = [];
var startPage = (page -1) * 2;
var totalCount = startPage + limit;
console.log(store.proxy.data);
for (var i = startPage; i < totalCount ; i++) {
dataResult.push(store.proxy.data.items[i]);
}
store.proxy.data.items = dataResult;
store.proxy.data.total = 4;
}
}
});
var TOTAL = 94; //random
// specify segment of data you want to load using params
store.loadPage(1);
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()
});
});
请在此处查看演示:- http://jsfiddle.net/B6qBN/