1. #1
    Sencha User
    Join Date
    Apr 2007
    Posts
    49
    Vote Rating
    0
    Green is on a distinguished road

      0  

    Default Unanswered: MVC Controller ref store or pollingprovider

    Unanswered: MVC Controller ref store or pollingprovider


    Hi,

    I have tried various permutations, but can not figure out how to ref either a store or pollingprovider in my app.Controller. I even tried to autoCreate these components within the controller but without success. Creating them in the app.Launch works just fine, but then I can't "ref" them and hook their events. Any help would be welcome, tia.

    Code:
    Ext.define('MyApp.controller.ctrlMain', {
        extend: 'Ext.app.Controller',
        config: {
            refs: {
                sightTab: 'tabbar button[iconCls=search]',
                tweetTab: 'tabbar button[iconCls=chat3]',
                sightstore: '#storeSightings', // which I added both as id and storeId to my store
                pollProvider: '#poll1', // which I added both as id and itemId to my pollingprovider
            },
            control: {
                pollProvider: {
                    data: 'pollData'
                },
                sightstore: {
                	load: 'sightingsLoaded'
    			}
            }
        },
        pollData: function() {  // This never fires
        	alert('poll'); 
    	},
        sightingsLoaded: function() {   // This never fires
        	alert('load'); 
    	}
    });
    Production: Ext4/Touch2

    "Real programmers use C: >copy con > myprog.exe"

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,398
    Answers
    3549
    Vote Rating
    849
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    refs are only for components. A store or PollingProvider are not components, they are just classes.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    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.

  3. #3
    Sencha User
    Join Date
    Apr 2007
    Posts
    49
    Vote Rating
    0
    Green is on a distinguished road

      0  

    Default


    Thanks much, explains it.

    Does not make sense though. Strictly speaking using the MVC paradigm, all Control should after all be manageable/implementable in the controller(s).

    Surely it would not be such a big jump from being able to ref UI components as well as any other types of non-UI controls like stores, direct providers, etc. One could even limit the Controller to resolve using ComponentQuery like now, and then just for the fun of it, check if the ref is not contained in the Application object. All the rest works the same, how events are hooked up, how callbacks are used, etc. The only limitation currently that the refs are synthetically limited to components only, instead of all Ext objects in the application.

    Bit silly to use a MVC methodology and then have to split your Control functionality between UI and non-UI events - makes everything messy again.

    Now one have to create one half the components in the app.js, the other half in views/controllers; handle the one half of the events here, and the rest there. All whilst all the events usually end up influencing the UI in some way.

    Just my 2 cents.
    Production: Ext4/Touch2

    "Real programmers use C: >copy con > myprog.exe"

  4. #4
    Sencha User
    Join Date
    Jun 2012
    Posts
    46
    Answers
    7
    Vote Rating
    3
    Malro is on a distinguished road

      0  

    Default


    So what is best practise to handle a store-event in controller?

  5. #5
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,398
    Answers
    3549
    Vote Rating
    849
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Quote Originally Posted by Malro View Post
    So what is best practise to handle a store-event in controller?
    Resolve the store and use the on method
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    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.

Thread Participants: 2

Tags for this Thread