Atleast from 5.1.2 you can pass includedOptions object to treestore#each method:
I tried using 5.1.1.451-Gray in fiddle , it still displayed only expanded nodes. It worked fine though after copying TreeStore.js code to fiddle.
So this is what you can do:
Ext.getStore('treestore').each(function(record,id){
if(record.id !== 'root')
console.log(record.data.name);
},this,{collapsed:true});
You can also pass filtered:true in third parameter object to include filtered out nodes.
Here is a full example you can copy to fiddle and run:
Ext.application({
name : 'Fiddle',
launch : function() {
Ext.define('myApp.Territory', {
extend: 'Ext.data.TreeModel',
fields: [{
name: 'text',
mapping: 'name'
}]
});
Ext.define('myApp.Country', {
extend: 'Ext.data.TreeModel',
fields: [{
name: 'text',
mapping: 'name'
}]
});
Ext.define('myApp.City', {
extend: 'Ext.data.TreeModel',
fields: [{
name: 'text',
mapping: 'name'
}]
});
var tp = Ext.create('Ext.tree.Panel', {
renderTo: document.body,
height: 200,
width: 400,
title: 'Sales Areas - using typeProperty',
rootVisible: false,
store: {
// Child types use namespace of store's model by default
storeId:'treestore',
model: 'myApp.Territory',
proxy: {
type: 'memory',
reader: {
typeProperty: 'mtype'
}
},
root: {
children: [{
name: 'Europe, ME, Africa',
mtype: 'Territory',
children: [{
name: 'UK of GB & NI',
mtype: 'Country',
children: [{
name: 'London',
mtype: 'City',
leaf: true
}]
}]
}, {
name: 'North America',
mtype: 'Territory',
children: [{
name: 'USA',
mtype: 'Country',
children: [{
name: 'Redwood City',
mtype: 'City',
leaf: true
}]
}]
}]
}
}
});
Ext.getStore('treestore').each(function(record,id){
if(record.id !== 'root')
console.log(record.data.name);
},this,{collapsed:true});
}
});