How to loop over each element in a Sencha Touch or ExtJS Store

As a quick example of how to loop over each element in a Sencha Touch or ExtJS store, I use the following code to dynamically create a series of checkboxes.

In short, in a Sencha controller:

Ext.define('Focus.controller.Projects', {
    extend: 'Ext.app.Controller',

I declare a Store:

stores: [
    'Tasks'
],

then later create a reference to the Store:

var tasksStore = this.getTasksStore();

then pass that Store reference into a function, where I iterate over each item in the store with the each method to build a series of checkboxes:

addCheckboxesToGroup: function(tasksStore, group) {
    var me = this;
    var count = 1;
    tasksStore.each(function(record) {
        var task = record.data.description;
        var checkbox = me.createCheckbox(task, count++);
        me.addCheckboxToGroup(group, checkbox);
    });
},

See the URL I’ve linked to for several examples of how to loop over each element in a Sencha Store.