Results 1 to 6 of 6

Thread: best practice for MVC auto-creation of views with multiple profiles

  1. #1
    Sencha User jep's Avatar
    Join Date
    Sep 2010
    Posts
    862
    Vote Rating
    24
      0  

    Default best practice for MVC auto-creation of views with multiple profiles

    I have an app with phone and tablet profiles. It has a view with a button that brings up another view. In the tablet version, this new view is simply a floating window shown next to the button. In the phone version, it is a whole screen that is switched to.

    I'm trying to figure out what the best practice is for this situation. Is it to give each profile view a different xtype and then create two separate refs, one in each controller like:

    phone controller:
    Code:
          myView:{
            selector:'someViewPhone',
            xtype:'someViewPhone',
            autoCreate:true
          },
    tablet controller:
    Code:
          myView:{
            selector:'someViewTablet',
            xtype:'someViewTablet',
            autoCreate:true
          },
    ?

    Then in the phone controller's click for the button:

    Code:
        Ext.Viewport.add(this.getMyView());
        Ext.Viewport.setActiveItem(1);
    and in the tablet controller:
    Code:
        this.getMyView().showBy(this.getMyButton());
    ?

    Or is there some more elegant way to go about this?

  2. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,556
    Vote Rating
    1272
      0  

    Default

    Each profile should have it's own controller. I usually have a base controller and have the phone/tablet controllers extend it so I can reuse that base code but put the profile specific logic in the profile controllers.
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

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

  3. #3
    Sencha User jep's Avatar
    Join Date
    Sep 2010
    Posts
    862
    Vote Rating
    24
      0  

    Default

    Yes, mitchell, that's why I specified in my tablet that I have a phone and a tablet controller (along with the base one). My question was about what to do to create the controller-specific view. Check out my question again.

  4. #4
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,556
    Vote Rating
    1272
      0  

    Default

    Checkout my reply again. If you have a base controller that can handle say a button click but what happens on that button click is profile specific, now different controllers can take over.
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

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

  5. #5
    Sencha User jep's Avatar
    Join Date
    Sep 2010
    Posts
    862
    Vote Rating
    24
      0  

    Default

    That's what I'm doing, mitchell. I'm not asking about the controllers so much as the VIEWS. Notice my question about having two different xtypes.

  6. #6
    Sencha User siebmanb's Avatar
    Join Date
    Aug 2011
    Location
    Geneva (CH) - Grenoble (FR)
    Posts
    253
    Vote Rating
    16
      0  

    Default

    I think I understand what you mean and I believe you will find your answer there : http://www.sencha.com/forum/showthre...les-amp-xtypes

Posting Permissions

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