Search code examples
javascriptextjssencha-touchsencha-touch-2

Sencha store's each function the console.log not work


I want to display the records, but when I test it to display the data on console use record.get(''), it not work . even I tap the static code console.log('some thing'). It also cant display on my console.

The code in my controller:

it near the //-------here it is

Ext.define('ylp2p.controller.addtab',{
extend: 'Ext.app.Controller',

config: {
    refs: {
        myTabPanel: '.makemoney #tabfirst',
    },
    control: {
        myTabPanel: {
            activate: 'onActivateTabPanel',
            activeitemchange: 'onActiveItemChangeTabPanel'
        }
    }
},
launch: function(){
    var products = Ext.getStore('productstore');

    products.filterBy(function(record, id){
       return record.get('loanname') === 'xixi22';
    });
},

onActivateTabPanel: function(newActiveItem, viewport, oldActiveItem, eOpts) {
    //test
    console.log('hello the activatetabpanel is fire!');
    //end test success
    var tabs = Ext.getStore('loanliststore');
    tabs.each(function(record) {
        console.log('hello come on');//---------------------here it is
        newActiveItem.add({
            title: record.get('loanname')
        });
        console.log('');
    });
},

onActiveItemChangeTabPanel: function(cmp, value, oldValue, eOpts) {
    console.log('hello this is the activechangepanel is fire!');  
    var products = value.getStore();

    products.clearFilter(true);
    products.filterBy(function(record, id) {
        return record.get('loanname') === value.getTitle();
    });
}

});

Solution

  • Check by tabs.getCount() if it is greater then 0 then it should work. If not means there is no data populated in your store.