Hybrid View
-
10 May 2011 8:22 AM #1
[4.0.0] Bug in AbstractView.updateIndexes
[4.0.0] Bug in AbstractView.updateIndexes
Hi,
Believe I've found an issue in updateIndexes.
It's seems to be getting called when calling removeAll on a tree node, during a load (when clearOnLoad is true).
Anyway, code:
The issue is that sometimes records[i] is outside of the bounds of the collection.PHP Code:updateIndexes : function(startIndex, endIndex) {
var ns = this.all.elements,
records = this.store.getRange();
startIndex = startIndex || 0;
endIndex = endIndex || ((endIndex === 0) ? 0 : (ns.length - 1));
for(var i = startIndex; i <= endIndex; i++){
ns[i].viewIndex = i;
ns[i].viewRecordId = records[i].internalId;
if (!ns[i].boundView) {
ns[i].boundView = this.id;
}
}
},
Not entirely sure why, or what this method is meant to be doing, but it could probably be a bit more defensive I think.
Cheers,
Westy
-
10 May 2011 8:41 AM #2
I've seen this once before, and I can't remember how I got around it - but if ns (this.all.elements) has length 0, and both startIndex and endIndex are 0, that would happen...
-
10 May 2011 8:54 AM #3
I'm generally seeing it on the last child node... have kind of worked around it for now, but it's leaves the UI in a mess.
Basically overridden my tree view's updateIndexes, and put a try..catch around callParent; meaning I get nodes staying in the tree, but at least I can keep testing, which is sufficient for my current focus.
Cheers
-
11 May 2011 2:33 AM #4
My override for the moment:
But I suspect there's some underlying problem causing this.store.getRange to not return a set that matches this.all.elements length.PHP Code:updateIndexes : function(startIndex, endIndex) {
var ns = this.all.elements,
records = this.store.getRange();
startIndex = startIndex || 0;
endIndex = endIndex || ((endIndex === 0) ? 0 : (ns.length - 1));
for(var i = startIndex; i <= endIndex; i++){
ns[i].viewIndex = i;
ns[i].viewRecordId = records.length >= i ? records[i].internalId : undefined;
if (!ns[i].boundView) {
ns[i].boundView = this.id;
}
}
},
Cheers,
Westy
-
11 May 2011 5:18 AM #5
There are definitely some things that are in need of null and range checking...
stevil
-
11 May 2011 5:32 AM #6
Hello,
I have also an issue with AbstractView.updateIndexes / reloading a TreeStore.
I discovered a problem when reloading a TreeStore quick successive order.
Here is my store configuration:
This is what I do in my controller:PHP Code:Ext.define('Rekuma.store.Reseller.Tree', {
extend: 'Ext.data.TreeStore',
model: 'Rekuma.model.TreeNode',
autoLoad: true,
clearOnLoad: true,
proxy: {
type: 'ajax',
url : 'menu/reseller',
actionMethods: {
read : 'POST'
},
extraParams: {
category: 'reseller'
}
}
}
);
Everything works fine as long as I press the refresh button slowly.PHP Code:Ext.define('Rekuma.controller.Navigation', {
extend: 'Ext.app.Controller',
views: [
'navigation.PrimaryTreePanel'
],
stores: [
'Reseller.Tree'
],
init: function() {
this.control({
'viewport > panel > primarytreepanel': {
selectionchange: this.selectionChanged
},
'viewport > panel > primarytreepanel > toolbar > button': {
click: this.refresh
}
});
},
selectionChanged: function (view, selections){
},
refresh: function() {
this.getResellerTreeStore().load();
}
});
If I load the store in a quick, successive order, I get the message:
Also, I see TreeNodes twice.Code:TypeError: Result of expression 'records[i]' [undefined] is not an object. AbstractView.js:492
I get the same behavior on every click, if I set clearOnLoad: false
Stefan
-
12 May 2011 6:36 AM #7
Whoops, bug in this.
Fixed:
PHP Code:updateIndexes : function(startIndex, endIndex) {
var ns = this.all.elements,
records = this.store.getRange();
startIndex = startIndex || 0;
endIndex = endIndex || ((endIndex === 0) ? 0 : (ns.length - 1));
for(var i = startIndex; i <= endIndex; i++){
ns[i].viewIndex = i;
ns[i].viewRecordId = ((records.length > i) && records[i]) ? records[i].internalId : undefined;
if (!ns[i].boundView) {
ns[i].boundView = this.id;
}
}
},
-
10 Jun 2011 7:14 AM #8
I am still getting this error in 4.0.2. Your fix seems to work great (as I am no longer getting errors in my console window). Are the Sencha team aware of this?
Wait! Looks like we don't have enough information to add this to bug database. Please follow this template bug format.
Similar Threads
-
[2.0??][DUP][SOLVED] DataView bug in updateIndexes()
By Egor in forum Ext 2.x: BugsReplies: 2Last Post: 26 Nov 2007, 5:40 PM -
[2.0rc1][SOLVED][DUP] Ext.DataView, refreshNode, updateIndexes
By christocracy in forum Ext 2.x: BugsReplies: 3Last Post: 17 Nov 2007, 9:27 AM


Reply With Quote