1. #1
    Sencha User chris_nl's Avatar
    Join Date
    Nov 2011
    Location
    Amstedam
    Posts
    34
    Vote Rating
    0
    Answers
    1
    chris_nl is on a distinguished road

      0  

    Question Answered: At what point can you acces json data and apply it to a component.

    Answered: At what point can you acces json data and apply it to a component.


    Hello,
    I have a working List item that uses a model and store. In the model i load a external json file.
    It works great.
    I found a way to acces this data and use it for another component (the footerbar with buttons on it)

    The problem is that when I want to acces the data, it is not loaded yet or not accesable, so for now I
    did a very dirty solotion and put a delay on it. But I was wondering if there is an event or a better way to
    get the data when it's loaded? Thanks in advance.

    This is how it works now:

    Inside the conroller:
    Code:
    launch : function() { 
    
        var me = this;
         setTimeout(function(){
                       me.setFooterIconsData();
                   },100);
    
    
    }
    
    
     setFooterIconsData : function() {
             var me = this;
             var ft   = me.getFooterMenu();
             var tot = ft.items.items.length;
    
    
             var localStore = Ext.getStore('Pages');
    
    
             for(var i = 0; i< tot; i++ ){
                var newtitle = localStore.data.items[i].data.iconName;
                ft.items.items[i].setTitle(newtitle);
             }
        },
    The Model that I use:
    Code:
    //The model 
    
    
    Ext.define('Lericrystal.model.Page', {
        extend : 'Ext.data.Model',
    
    
        fields : [
            { name : 'id',       type : 'int' },
            { name : 'xtype',    type : 'string'},
            { name : 'name',     type : 'string' },
            { name : 'iconName', type : 'string' },
            { name : 'image',    type : 'string' },
            { name : 'content',  type : 'string' }
        ],
    
    
    
    
    
    
        proxy : {
            type   : 'ajax',
            url    : 'resources/pages.json',
            reader : {
                type            : 'json',
                root            : 'pages',
                successProperty : 'success',
                totalProperty   : 'total'
            }
        }
    And the store:
    Code:
    //The Store
    
    
    Ext.define('Lericrystal.store.Pages', {
        extend : 'Ext.data.Store',
    
    
        model    : 'Lericrystal.model.Page',
        autoLoad : true
    });

  2. PHP Code:
    var localStore Ext.getStore('Pages');
    localStore.on("load",function() {
        
    //Data should be ready here  
      //Plus the data list is passed as the 2nd or 3rd argument i don't remember
    }); 

  3. #2
    Sencha User
    Join Date
    Jan 2012
    Posts
    9
    Vote Rating
    0
    Answers
    2
    Lou-adrien is on a distinguished road

      0  

    Default


    PHP Code:
    var localStore Ext.getStore('Pages');
    localStore.on("load",function() {
        
    //Data should be ready here  
      //Plus the data list is passed as the 2nd or 3rd argument i don't remember
    }); 

  4. #3
    Sencha User chris_nl's Avatar
    Join Date
    Nov 2011
    Location
    Amstedam
    Posts
    34
    Vote Rating
    0
    Answers
    1
    chris_nl is on a distinguished road

      0  

    Red face


    Thanks Lou-adrien for your reply! It worked !

Thread Participants: 1