javascript - ExtJS View properties depending on (controller-side) flag -


i defined view should able called in 2 modes. there 2 differences depending on flag:

  • title of view (config.title)
  • selectfield might shown or hidden

here simplified view:

ext.define('myapp.view.fancyview', {  xtype: 'fancyview', extend: 'ext.form.panel',  config: {     cls: 'fancyviewclass',      title: "titledependingonflag",      items: [         {             xtype: 'fieldset',             name: 'fieldsetfancy',             items: [                 {                     xtype: 'selectfield',                     itemid: 'stateid',                     usepicker: true,                     label: 'state',                     store: 'states',                     name: 'stateid',                     valuefield: 'id',                     displayfield: 'id'                 },                 {                     xtype: 'selectfield',                     itemid: 'countryid',                     usepicker: true,                     label: 'country',                     store: 'countries',                     name: 'countryid',                     valuefield: 'id',                     displayfield: 'id',                     //hidden: true                 }             ]         }     ] } }); 

and of course there controller creates view. @ moment i'm passing flag config value, see

ext.define('myapp.controller.fancycontroller', {  ... raisedbasedontap:function (flag){ this.myfancyflag = !!flag;      var myfancyview = ext.create('flsmobile.minimax.view.callreporttimestampplacecar', {         myfancyflag: me.myfancyflag         });      app.pushview(myfancyview);  } ... }); 

what best approach make title depending on flag (like title: fancyflag? 'title1' : 'title2') , hide selectfield countryid based on flag?

thanks in advance!


Comments