2017-09-25 6 views
0

私はExtJS 3.3.0を使用しており、コンボボックスに値があるまで保存ボタンを無効にしたい。ExtJS 3.3.0コンボボックスに値があるまで保存ボタンを無効にする

私はそのようにコンボボックスを作成しています。

new Ext.form.ComboBox({ 
    id: this.idName + 'Combo_StateID', 
    name: 'StateID', 
    fieldLabel: 'State', 
    singleOnly: true, 
    typeAhead: true, 
    triggerAction: 'all', 
    store: StateStore, 
    mode: 'remote', 
    valueField: 'StateID', 
    hiddenField: 'StateID', 
    displayField: 'StateNumber', 
    lazyInit: false, 
    listClass: 'x-combo-list-small', 
    tpl: '<tpl for=\".\"><div class=\"x-combo-list-item\"><span style=\"width: 50px;\">#{StateNumber}</span></div></tpl>', 
}), ") . " 

私は単純にボタンを作成しています。

newPanel.addButton(
    { 
     iconCls:'icon-ok', 
     text: 'Save Data' 
    } 
) 

これはすべて問題なく動作します。ボタンを無効にすると、私は全く理解できません。

私は以下を試しましたが、それでも何もありません。

listeners: { 
afterrender: function() { 
    if (this.getValue() === null) { 
    Ext.getCmp('yourButton').setDisabled(true); 
     } 
    else { 
     Ext.getCmp('yourButton').setDisabled(false); 
     } 
    } 
} 

あなたはコンポーネントのレンダリングが終了した後afterrenderそれは意志戦火を使用してきたようにすべてのヘルプは大

+0

使用を働いているか、ここで確認してください。 –

答えて

0

をいただければ幸いです。

私はデモを作成しているExtJS Combobox

の方法を選択を使用してみてください。値が設定されていない場合のgetValue()は空の文字列を返しますので、あなたは(this.getValue()===「」)場合、それはSencha fiddle

Ext.onReady(function() { 
    var PanelMain = Ext.extend(Ext.Panel, { 
      title: 'My Panel', 
      initComponent: function() { 
       Ext.applyIf(this, { 
        items: [{ 
         xtype: 'combo', 
         typeAhead: true, 
         triggerAction: 'all', 
         lazyRender: true, 
         mode: 'local', 
         store: new Ext.data.ArrayStore({ 
          id: 0, 
          fields: [ 
           'myId', 
           'displayText' 
          ], 
          data: [ 
           [1, 'item1'], 
           [2, 'item2'] 
          ] 
         }), 
         valueField: 'myId', 
         displayField: 'displayText', 
         editable: false, 
         listeners: { 
          select: function (combo, record) { 
           Ext.getCmp('saveButton').setDisabled(false); 
          } 
         } 
        }, { 
         xtype: 'button', 
         id: 'saveButton', 
         iconCls: 'icon-ok', 
         disabled: true, 
         text: 'Save Data', 
         handler: function() { 
          //here you can put your logic.. 
         } 
        }] 
       }); 
       PanelMain.superclass.initComponent.call(this); 
      } 
     }), 
     panel = new PanelMain({ 
      renderTo: Ext.getBody() 
     }); 

}); 
関連する問題