Here is my task store and when I try to get its records using store.each it gives me TypeError: store.each is not a function
store = Ext.create('Ext.data.TreeStore', {
model: 'Task',
folderSort: true,
sortInfo: {
field: "StartDate",
direction: "ASC"
},
root:
{
text: '.',
expanded: true,
children: arrTasksData
}
});
I have a button on click of it I need to access store records.I am using below code to access records.
console.log(store.getCount()); //Prints undefined
store.each(function (record,id) {
console.log(record.get("TaskName"));
});
The above code gives me error in console : TypeError: store.each is not a function
Though console.log(store) prints object But console.log(store.getCount()) prints undefined.
TreeStore uses nested structure for its data. When you look at the API document from Sencha (http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.data.TreeStore), there's no getCount() method available for you to use. For dealing with Frameworks, API document is your best friend!
So, your store.getCount() won't work. You need to write your own function for counting leaf nodes for that matter.
I wrote a simple Fiddle code for that purpose. Please note that this hasn't been fully tested with various data. This is just to give you some idea on what needs to be done.