View Full Version : [INFOREQ] [] TreeStore.onBeforeExpand

13 Feb 2013, 2:44 PM
Took me a while to find the culprit.

Few thing with this method:

1- the return value of (node.raw || node[node.persistenceProperty])[(reader = me.getProxy().getReader()).root]) is likely to be "true". You then try to evaluate me.fillNode(node, reader.extractData(true)), which does not make a lot of sense (we should have childNodes instead here).
2- As the return value of above is truthly, elseif (node.isLoading()) {... is never called. That can be problematic - at least was with my code.
3- With the current configuation, sames nodes can be loaded multiple times. We might need a return if node.isLoaded()

onBeforeNodeExpand: function(node, callback, scope) {
var me = this,
reader, dataRoot, data;

// Children are loaded go ahead with expand
if (node.isLoaded()) {
Ext.callback(callback, scope || node, [node.childNodes]);
} else if (node.childRecords) {

// There are unloaded child nodes in the raw data because of the lazy configuration, load them then call back.
else if (dataRoot = (data = (node.raw || node[node.persistenceProperty])[(reader = me.getProxy().getReader()).root])) {
me.fillNode(node, reader.extractData(dataRoot));
delete data[reader.root];
Ext.callback(callback, scope || node, [node.childNodes]);
//else if (node.isLoading()) {
if (node.isLoading()) {
me.on('load', function() {
Ext.callback(callback, scope || node, [node.childNodes]);
}, me, {single: true});
else {
node: node,
callback: function() {
// Clear the callback, since if we're introducing a custom one,
// it may be re-used on reload
delete me.lastOptions.callback;
Ext.callback(callback, scope || node, [node.childNodes]);

15 Feb 2013, 7:05 AM
Can I get a runnable test case?