Results 1 to 3 of 3

Thread: Fire Event from Store and receive in List view

  1. #1
    Sencha User
    Join Date
    Apr 2012
    Posts
    52
    Answers
    3
    Vote Rating
    0
      0  

    Default Answered: Fire Event from Store and receive in List view

    How do I get that alert to fire in the List view upon store loading?

    Coffeescript:

    List:
    Code:
    Ext.define 'WSI.view.EventsList',
      extend: 'Ext.List'
      xtype: 'eventslist'
      config:
        listeners:
          showLoading: ->
            alert 'showLoading in EventsList heard'
            @fireEvent 'showLoading', 0
    Store:
    Code:
    Ext.define 'WSI.store.Events',
      extend: 'Ext.data.Store'
      xtype: 'eventsstore'
      config:
        model: 'WSI.model.Event'
        autoLoad: false
        pageSize: 15
        listeners:
          beforeload: ->
            @fireEvent 'showLoading', 0
          load: ->
            @fireEvent 'hideLoading', 0

  2. You would have to fire the event on the store and then add a listener within the list to listen to it:

    Code:
    Ext.define('MyList', {
        extend : 'Ext.dataview.List',
        xtype  : 'my-list',
    
        //...
    
        updateStore: function(newStore, oldStore) {
            if (oldStore) {
                oldStore.un('storeLoading', 'onStoreLoading', this);
            }
    
            if (newStore) {
                newStore.on('storeLoading', 'onStoreLoading', this);
            }
        },
    
        onStoreLoading : function() {
            //....
        }
    });
    Man, IMO Coffeescript is ugly

  3. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,411
    Answers
    3898
    Vote Rating
    1290
      0  

    Default

    You would have to fire the event on the store and then add a listener within the list to listen to it:

    Code:
    Ext.define('MyList', {
        extend : 'Ext.dataview.List',
        xtype  : 'my-list',
    
        //...
    
        updateStore: function(newStore, oldStore) {
            if (oldStore) {
                oldStore.un('storeLoading', 'onStoreLoading', this);
            }
    
            if (newStore) {
                newStore.on('storeLoading', 'onStoreLoading', this);
            }
        },
    
        onStoreLoading : function() {
            //....
        }
    });
    Man, IMO Coffeescript is ugly
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it!

    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  4. #3
    Sencha User
    Join Date
    Apr 2012
    Posts
    52
    Answers
    3
    Vote Rating
    0
      0  

    Default

    Thanks!

    Funny, I thought coffeescript looked so nice and it saves so many commas when using Sencha Touch. It can be cluttered though because if you space it out too much then it can get confusing.

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
  •