Results 1 to 2 of 2

Thread: Scope: can't capture events from a Store in a ViewController

  1. #1
    Sencha Premium Member
    Join Date
    Aug 2014
    Posts
    31
    Answers
    2
    Vote Rating
    2
      0  

    Default Scope: can't capture events from a Store in a ViewController

    I'm working on a very simple panel with a ViewController. I'm not able to capture the events of my store into the controller, the scope of the store's events are the store itself.

    Code:
    Ext.define('MyApp.view.TestPanelViewController', {
        extend: 'Ext.app.ViewController',
        alias: 'controller.testpanel',
        onLoad: function (comp, records, successful, eOpts) {
            console.log('beforeload event');
        }
    });
    
    Ext.define('MyApp.view.TestPanel', {
        extend: 'Ext.grid.Panel',
        alias: 'widget.testpanel',
        defaultListenerScope: true,
        store: {
            autoLoad: true,
            listeners: {
                beforeload: function () {
                    console.log('beforeload event');
                },
                load: 'onLoad'
            }
        },
        controller: 'testpanel'
    });
    The output is :
    HTML Code:
    beforeload event
    [E] No such method onLoad on Ext.data.Store
    Store's scope work differently than components ?

    According to this post (and what I understood of ViewController) listeners of the View usually correctly find the 'top controller' from string events.

    thanks

  2. #2
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,379
    Answers
    3997
    Vote Rating
    1524
      0  

    Default

    A ViewController is for views, a store is not a view so the binding is not there. You can use a ViewModel to instantiate and hold your store and your controller can get access to it. You can bubble store events from your view to your controller.
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Frontend Engineer
    ________________
    Need any sort of Ext JS help? Modus Create is here to help!

    Check out my GitHub:
    https://github.com/mitchellsimoens

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •