1. #1
    Sencha User
    Join Date
    Jun 2013
    Posts
    9
    Vote Rating
    0
    locs is on a distinguished road

      0  

    Default callback load function and scope

    callback load function and scope


    Hi i try to generate menu with data in database, with the desktop example of sencha.
    But i'm not able to add menu item in the start menu. I have my record in my datastore and when i'm using the callback function on load event, the cfg.menu.push function doesn't want to work.
    Code:
    this.navStore = new Ext.data.Store({
                storeId: 'menuPere',
                fields: ['Intitule','ProgrammeAppele','menupere','CodeEntreeMenu'],
                autoLoad: true,
                proxy: new Ext.data.HttpProxy({
                    url: 'generateMenuPere',
                    reader: {
                        type: 'json',
                        root: 'items',
                        totalProperty: 'count'
                    },
                    pageParam: false, //to remove param "page"
                    startParam: false, //to remove param "start"
                    limitParam: false, //to remove param "limit"
                    noCache: false //to remove param "_dc"
                })
            });
            this.navStore.load({
                callback    : function(records, operation, success) {
                    alert('ici');
                    cfg.menu.push({
                        text: '2 ',
                        iconCls:'bogus',
                        handler : this.createWindow,
                        scope: this
                    });    
                    for (var i=0; i<records.length; i++) {
                            //alert( records[i].data.intitule);
                    } 
                },
                scope: this
            });
    I think it's a scope problem because i put the cfg.menu.push out of the callback that's work well. Does someone can help me?
    Thanks a lot

  2. #2
    Sencha - Support Team slemmon's Avatar
    Join Date
    Mar 2009
    Location
    Boise, ID
    Posts
    5,993
    Vote Rating
    212
    slemmon has much to be proud of slemmon has much to be proud of slemmon has much to be proud of slemmon has much to be proud of slemmon has much to be proud of slemmon has much to be proud of slemmon has much to be proud of slemmon has much to be proud of

      0  

    Default


    Is the menu instantiated already by the time you're looking to push an item into the menu array? If so, perhaps what you're wanting to do is a menu.add?
    Are you a Sencha products veteran who has wondered what it might be like to work at Sencha? If so, please reach out to our recruiting manager: sheryl@sencha.com

Thread Participants: 1