2012-01-24 7 views
0

私は次に行う必要があります:いくつかのボタンがあります。いずれかのボタンを押すとフォームの状態が変わるので、いくつかのボタンが見えなくなります。 私は、コンストラクタから呼び出すとき、私はextJSのコンポーネントを塗り直す

Loyalty.company.CompanyEditForm = Ext.extend(Loyalty.tools.AdvancedForm, 
    { 
     defaultConfig:{ 
      ...... 
      currentState: 'READONLY' 
      // EDIT, CREATE, CREATE_EDIT 
     }, 


     constructor:function (config) { 
      Ext.apply(config, this.defaultConfig); 
      config['owner'] = this; 
      config['items'] = []; 
      config['items'] = this.createItems(config); 
      config['buttons'] = this.createButtons(config); 
      Loyalty.company.CompanyEditForm.superclass.constructor.call(this, config); 
      this.loadCompany(config['jsonCompany']); 
      this.renderingView(config);// here it's ok 
     }, 

.... 

     renderingView:function (config){ 
      if (config.currentState == 'READONLY'){ 
       this.items.items[0].disabled = false; 
       Ext.ComponentQuery.query('#cardNumber')[0].disabled = true; 
       Ext.ComponentQuery.query('#btnEdit')[0].hidden = false; 
       Ext.ComponentQuery.query('#btnRewrite')[0].hidden = true; 
       Ext.ComponentQuery.query('#btnSubmit')[0].hidden = true; 
       Ext.ComponentQuery.query('#btnCancel')[0].hidden = false; 
      } else if (config.currentState == 'EDIT'){ 
       this.items.items[0].disabled = false; 
       Ext.ComponentQuery.query('#cardNumber')[0].disabled = false; 
       Ext.ComponentQuery.query('#btnEdit')[0].hidden = true; 
       Ext.ComponentQuery.query('#btnRewrite')[0].hidden = true; 
       Ext.ComponentQuery.query('#btnSubmit')[0].hidden = false; 
       Ext.ComponentQuery.query('#btnCancel')[0].hidden = false; 
      } else if (config.currentState == 'CREATE'){ 
       Ext.ComponentQuery.query('#cardNumber')[0].disabled = false; 
       Ext.ComponentQuery.query('#btnEdit')[0].hidden = true; 
       Ext.ComponentQuery.query('#btnRewrite')[0].hidden = false; 
       Ext.ComponentQuery.query('#btnSubmit')[0].hidden = false; 
       Ext.ComponentQuery.query('#btnCancel')[0].hidden = false; 
      } 
      this.owner.doComponentLayout() 
      return null; 
     }, 



     createButtons:function (config, form) { 
      return [ 
       { 
        id: 'btnEdit', 
        text:Loyalty.messages['company.edit.fields.edit'], 
        handler:function() { 
         config.currentState = 'EDIT'; 
         config.owner.renderingView(config) 
        } 
       } , 
       { 
        xtype:'button', 
        id: 'btnRewrite', 
        text:Loyalty.messages['company.edit.fields.rewrite'], 
        handler:function() { 
         config.currentState = 'READONLY'; 
         config.owner.renderingView(config) 
        } 
       }, 
       { 
        xtype:'button', 
        id: 'btnSubmit', 
        text:Loyalty.messages['company.edit.fields.submit'], 
        handler:function() { 
         config.currentState = 'CREATE_EDIT'; 
         config.owner.renderingView(config) 
        } 
       }, 
       { 
        xtype:'button', 
        id: 'btnCancel', 
        text:Loyalty.messages['company.edit.fields.cancel'], 
        handler:function() { 
         if (config.currentState == 'EDIT' || config.currentState == 'CREATE_EDIT'){ 
          config.currentState = 'READONLY'; 
          config.owner.renderingView(config) 
         } 
        } 
       } 
      ]; 
     }, 

     .... 
    } 
); 

機能renderingViewの中華鍋良い次のコードを書きました。しかし、ボタンメソッドから呼び出されると、何も起こりません。変更するボタンの状態(非表示)。 再ペイントの問題

答えて

0

ボタンハンドラを実行すると、設定オブジェクトが未定義と考えられます。 Chromeでエラースタックトレースを取得していますか?

+0

答えDmitryB – yaroslavTir

1

プロパティをrenderingViewに設定する代わりに、setVisiblesetDisabledのメソッドを使用する必要があります。

0

理由は非常に簡単でした。私がsetVisibled()とsetDisabled()を使用し始めた直後に、無効にされ、すべてが正しく隠されました。

関連する問題