这是我的商店:
Ext.define('NG.store.WhatsNews', {
extend: 'NG.store.AbstractStore',
model: 'NG.model.auxClasses.notifications.WhatsNew',
alias: 'store.whatsnewstore',
autoLoad:true,
buffered: true,
remoteFilter: true,
remoteGroup: true,
remoteSort: true,
pageSize: 50
});
当我向下滚动网格并且缓冲视图尝试加载新记录时,我收到错误'尝试在不存在的上下文中引用节点。'。
这是我在chrome dev工具上发现的错误。:
我看了变量,并且拖欠了这个号码:
me.view.bufferRender(newRecords, me.endIndex + 1)
导致节点数组与
的长度不同recCount = newRecords.length
在调用frag.appendChild(newNodes[i]);
时会导致错误。
这是一个已知的问题???
有解决方法吗?
更新
我创建了以下覆盖:
Ext.override(Ext.view.NodeCache, {
/**
* Appends/prepends records depending on direction flag
* @param {Ext.data.Model[]} newRecords Items to append/prepend
* @param {Number} direction `-1' = scroll up, `0` = scroll down.
* @param {Number} removeCount The number of records to remove from the end. if scrolling
* down, rows are removed from the top and the new rows are added at the bottom.
*/
scroll: function (newRecords, direction, removeCount) {
var me = this,
elements = me.elements,
recCount = newRecords.length,
i, el, removeEnd,
newNodes,
nodeContainer = me.view.getNodeContainer(),
frag = document.createDocumentFragment();
// Scrolling up (content moved down - new content needed at top, remove from bottom)
if (direction == -1) {
for (i = (me.endIndex - removeCount) + 1; i <= me.endIndex; i++) {
el = elements[i];
delete elements[i];
el.parentNode.removeChild(el);
}
me.endIndex -= removeCount;
// grab all nodes rendered, not just the data rows
newNodes = me.view.bufferRender(newRecords, me.startIndex -= recCount);
for (i = 0; i < recCount; i++) {
elements[me.startIndex + i] = newNodes[i];
frag.appendChild(newNodes[i]);
}
nodeContainer.insertBefore(frag, nodeContainer.firstChild);
}
// Scrolling down (content moved up - new content needed at bottom, remove from top)
else {
removeEnd = me.startIndex + removeCount;
for (i = me.startIndex; i < removeEnd; i++) {
el = elements[i];
delete elements[i];
el.parentNode.removeChild(el);
}
me.startIndex = i;
// grab all nodes rendered, not just the data rows
newNodes = me.view.bufferRender(newRecords, me.endIndex + 1);
for (i = 0; i < newNodes.length ; i++) {
elements[me.endIndex += 1] = newNodes[i];
frag.appendChild(newNodes[i]);
}
nodeContainer.appendChild(frag);
}
// Keep count consistent.
me.count = me.endIndex - me.startIndex + 1;
}
});
这可以防止在chrome中抛出错误,但最后一条记录没有显示!!!
任何有更好主意的人?
答案 0 :(得分:0)