PDA

View Full Version : [FIXED] TreeStore autoLoad



mbalsam
6 Jul 2011, 11:20 PM
Sencha Touch version tested:

1.1.0 (with PhoneGap)

only default ext-all.css




Platform tested against:

iOS 4
OSX (Chrome, Safari)


Description:

TreeStore with autoLoad property set to false
TreeStore used as store property of a NestedList
When the NestedList is instantiated the TreeStore automatically loads


Test Case:



var data = {
text: 'Groceries',
items: [{
text: 'Drinks',
items: [{
text: 'Water',
items: [{
text: 'Sparkling',
leaf: true
},{
text: 'Still',
leaf: true
}]
},{
text: 'Coffee',
leaf: true
},{
text: 'Espresso',
leaf: true
},{
text: 'Redbull',
leaf: true
},{
text: 'Coke',
leaf: true
},{
text: 'Diet Coke',
leaf: true
}]
},{
text: 'Fruit',
items: [{
text: 'Bananas',
leaf: true
},{
text: 'Lemon',
leaf: true
}]
},{
text: 'Snacks',
items: [{
text: 'Nuts',
leaf: true
},{
text: 'Pretzels',
leaf: true
},{
text: 'Wasabi Peas',
leaf: true
}]
},{
text: 'Empty Category',
items: []
}]
};
Ext.regModel('ListItem', {
fields: [{name: 'text', type: 'string'}]
});
var store = new Ext.data.TreeStore({
autoLoad: false,
model: 'ListItem',
root: data,
proxy: {
type: 'ajax',
reader: {
type: 'tree',
root: 'items'
}
},
listeners: {
beforeLoad: function() {
console.log('You didn't say store.load(), did you?');
}
}
});
var nestedList = new Ext.NestedList({
fullscreen: true,
title: 'Groceries',
displayField: 'text',
store: store
});


See this URL : http://


Steps to reproduce the problem:

Implement a TreeStore with autoLoad set to false
Use the TreeStore as a NestedList's store
Instantiate the NestedList


The result that was expected:

TreeStore does NOT load automatically
NestedList should not be responsible for loading the store (see e.g. List)


The result that occurs instead:

TreeStore loads automatically


Screenshot or Video:

no


Debugging already done:

NestedList.initComponent calls NestedList.getSubList which calls NestedList.getListConfig which finally calls NestedList.store.getSubStore. At this point the TreeStore loads.


Possible fix:

not provided

mike.estes
7 Jul 2011, 8:16 AM
Thanks for the report, please fill out this template (http://www.sencha.com/forum/showthread.php?104623-Posting-to-the-bug-forum) and include a test case demonstrating the bug.

mbalsam
7 Jul 2011, 11:46 PM
Sencha Touch version tested:

1.1.0 (with PhoneGap)

only default ext-all.css




Platform tested against:

iOS 4
OSX (Chrome, Safari)


Description:

TreeStore with autoLoad property set to false
TreeStore used as store property of a NestedList
When the NestedList is instantiated the TreeStore automatically loads


Test Case:



var data = {
text: 'Groceries',
items: [{
text: 'Drinks',
items: [{
text: 'Water',
items: [{
text: 'Sparkling',
leaf: true
},{
text: 'Still',
leaf: true
}]
},{
text: 'Coffee',
leaf: true
},{
text: 'Espresso',
leaf: true
},{
text: 'Redbull',
leaf: true
},{
text: 'Coke',
leaf: true
},{
text: 'Diet Coke',
leaf: true
}]
},{
text: 'Fruit',
items: [{
text: 'Bananas',
leaf: true
},{
text: 'Lemon',
leaf: true
}]
},{
text: 'Snacks',
items: [{
text: 'Nuts',
leaf: true
},{
text: 'Pretzels',
leaf: true
},{
text: 'Wasabi Peas',
leaf: true
}]
},{
text: 'Empty Category',
items: []
}]
};
Ext.regModel('ListItem', {
fields: [{name: 'text', type: 'string'}]
});
var store = new Ext.data.TreeStore({
autoLoad: false,
model: 'ListItem',
root: data,
proxy: {
type: 'ajax',
reader: {
type: 'tree',
root: 'items'
}
},
listeners: {
beforeLoad: function() {
console.log('You didn't say store.load(), did you?');
}
}
});
var nestedList = new Ext.NestedList({
fullscreen: true,
title: 'Groceries',
displayField: 'text',
store: store
});


See this URL : http://


Steps to reproduce the problem:

Implement a TreeStore with autoLoad set to false
Use the TreeStore as a NestedList's store
Instantiate the NestedList


The result that was expected:

TreeStore does NOT load automatically
NestedList should not be responsible for loading the store (see e.g. List)


The result that occurs instead:

TreeStore loads automatically


Screenshot or Video:

no


Debugging already done:

NestedList.initComponent calls NestedList.getSubList which calls NestedList.getListConfig which finally calls NestedList.store.getSubStore. At this point the TreeStore loads.


Possible fix:

not provided

mbalsam
11 Jul 2011, 11:13 PM
Bump... I have updated my initial post to match the template.

mbalsam
12 Jul 2011, 3:26 AM
I found the code, where the TreeStore.load is called. In NestedList's getListConfig method (which is called when the NestedList is created) store.getSubStore gets called which calls the getSubStore method of the selected recordNode (in this case the root node). The code of RecordNode.getSubStore looks like this:



getSubStore: function() {

if (this.isLeaf()) {
throw "Attempted to get a substore of a leaf node.";
}


var treeStore = this.getOwnerTree().treeStore;
if (!this.subStore) {
this.subStore = new Ext.data.Store({
model: treeStore.model
});



var children = this.getChildRecords();
this.subStore.add.apply(this.subStore, children);
}

if (!this.loaded) {
treeStore.load({
node: this
});
}
return this.subStore;
}


I marked the part where the TreeStore is loaded red.

So, once again, shouldn't the TreeStore only load when I, the developer, wants it, if autoLoad is set to false?

mbalsam
13 Jul 2011, 3:31 AM
filled out the template 6 days ago. would someone at least give me a sign if this is considered a bug or not?

apsbb
10 Aug 2011, 10:18 AM
I was experiencing the exact same problem. While still learning Sencha Touch this was driving me up the wall and I am happy to have found this topic. I have commented out the lines pointed out by mbalsam and now it's working as expected for me.

mike.estes
11 Aug 2011, 10:32 AM
sorry for the delay, we got this filed

mbalsam
15 Aug 2011, 1:35 AM
thanks for responding.

Justin Noel
15 Sep 2011, 4:01 AM
Same problem in ExtJS 4.0.6

TommyMaintz
16 Dec 2011, 11:11 AM
This is fixed in Touch as part of the next Touch 2.0 release.