[英]Extjs 4.2 buffered store throws Uncaught NotFoundError: An attempt was made to reference a Node in a context where it does not exist. on chrome
here is my store: 这是我的商店:
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
});
When I scroll the grid down and the buffered view tries to load the new records I get an error ' An attempt was made to reference a Node in a context where it does not exist. 当我向下滚动网格并且缓冲视图尝试加载新记录时,我得到一个错误' 尝试在不存在的上下文中引用Node。 '.
'。
Here is the error as I caught it on chrome dev tools.: 这是我在chrome开发工具上发现的错误:
I watched the variables and it arrears that the call for : 我看了看变量,并拖欠了对的呼吁:
me.view.bufferRender(newRecords, me.endIndex + 1)
results in an array of nodes that is not in the same length as 导致节点数组的长度与长度不同
recCount = newRecords.length
which causes an error when frag.appendChild(newNodes[i]);
当
frag.appendChild(newNodes[i]);
时会导致错误 is called. 叫做。
Is that a known issue??? 这是一个已知问题吗???
Is there a work around? 有没有解决的办法?
UPDATE 更新
I have created the following override: 我创建了以下替代:
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;
}
});
This prevents the error thrown in chrome but the last record does not show!!! 这样可以防止在chrome中抛出错误,但不会显示最后一条记录!!!
Anyone with a better idea? 有更好的主意吗?
It appears to be a known issue of ExtJS 4.2.1. 它似乎是ExtJS 4.2.1的已知问题。
http://www.sencha.com/forum/showthread.php?265323 http://www.sencha.com/forum/showthread.php?265323
And it was fixed under 4.2.2 它已在4.2.2下修复
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.