Hybrid View

  1. #1
    Sencha User
    Join Date
    May 2011
    Posts
    2
    Vote Rating
    0
    mmmilo is on a distinguished road

      0  

    Default Getting a reference to current view from controller

    Getting a reference to current view from controller


    Hi,

    Is there a way to get the current View in a Controller *without* setting a reference for it?

    Code:
    Ext.define('myapp.controller.ListingController', {
      extend: 'myapp.CommonController',
      
      config: {
        
        views: ['ListingView'],
        
        refs: {
          main: 'ListingView',
        },
    
    
        }
      },
    
    
      launch: function() {
        var bar = this.getMain().up('navigationview').getNavigationBar();
        bar.hide();
      },
        
        
    });

    In my example I have a View wrapped by a NavigationView. I want to hide the titlebar in the NavigationView. This code works fine.

    However if I want to use it elsewhere, I need to add a new ref, and change it accordingly, since getMain() is the important part here. That kind of defeats the purpose of DRY principles.

    What I'd *like* to do is to be able to create a generic hideTitleBar() function to CommonController (which just extends Ext.app.Controller), so I could just put:

    Code:
      launch: function() {
         this.hideTitleBar();
      },
    Is there something I'm missing?

    Thanks!

  2. #2
    Sencha User
    Join Date
    Mar 2012
    Location
    The Netherlands
    Posts
    75
    Vote Rating
    4
    SebasSP is on a distinguished road

      0  

    Default


    You can query down from Ext.Viewport

    Something like this:
    Code:
    var navviews = Ext.Viewport.query('navigationview');
    for(var i=0, l=navviews.length; i<l; i++){
        navviews[i].getNavigationBar().hide();
    }

  3. #3
    Sencha User
    Join Date
    Oct 2012
    Location
    Belo Horizonte, Brazil
    Posts
    5
    Vote Rating
    0
    leandroafonso is on a distinguished road

      0  

    Default You can extends Ext.controller.Controller

    You can extends Ext.controller.Controller


    I had a likelly context and make a extends class to Ext.controller.Controller on controller directory like as:
    Code:
    Ext.define('TecFoodApp.controller.Controller', {    extend: 'Ext.app.Controller',    activeDataStore: null,    backView: null,    slideLeftTransition: { type: "slide", direction: "left" },    slideRightTransition: { type: 'slide', direction: 'right' },       onBackToCommand:function(view){        Ext.Viewport.setActiveItem(view);        Ext.Viewport.animateActiveItem(view, this.SlideRightTransition);    },        onSaveCommand: function (form) {        var record = form.getRecord();        var values = form.getValues();        if (values.id > 0){            record.set(values);	}        else{            record = this.activeDataStore.getModel();            record.set(values);            this.activeDataStore.add(record);            novo = true;        }                this.activeDataStore.sync();        if (novo){ //faz reload para atualziar            this.activeDataStore.load();        }             this.onBackToCommand(this.backView);    },    onSetActiveDataStore:function(cmp){        this.activeDataStore =  cmp.getStore();        console.log("activeDataStore => " + this.activeDataStore.getStoreId());            },    onSetBackView:function(cmp){        this.backView =  cmp.getId();        console.log("backView => " + this.backView);            }})
    This class add a new method onBackToCommand wich opens a view passed as argument. note, backView property defined by me on this class.

    The views can now call the backtoview passing theirs name that maybe another extension on views that is a new challenge becouse view are a lot of components.

    to use my personalized controller may be like:

    Code:
     Ext.define('TecFoodApp.controller.OperadorController', {
        extend: 'TecFoodApp.controller.Controller',    stores:["Operadores","Processos"],    models:["Operador"],    config: {        refs: {            operadorListarView: "operadorlistarview",            operadorCadastrarView: "operadorcadastrarview"        },        control: {            operadorListarView: {                scope: this,                backToCommand: "onBackToCommand",                itemtap: "onItemTapCommand",                setActiveDataStore:"onSetActiveDataStore",                setBackView: "onSetBackView"            },            operadorCadastrarView: {                scope:this,                backToCommand: "onBackToCommand",                saveCommand: "onSaveCommand"            }        }    },....dropped.....
    worth considering the example my little experience in frame, I'm learning some things from architecture to develop something more solid.

Thread Participants: 2

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi