2012-03-14 2 views
2

이번에는 아이템을 표시하거나 사라지게하는 것이 좋습니다. 나는 그것이 hide()show()으로 끝난다는 것을 알고있다. 그러나 나는 어떻게 몰라? 내 코드는 다음과 같습니다. 나는 "selectfield"의 "약속"을 선택하면 아이템 숨기기 및보기

App.views.Bankingrendezvous = Ext.extend(Ext.Panel, { 

items: [{ 
xtype: 'formpanel', 
id: 'form', 
fullscreen: true, 
scroll: 'vertical', 
items: [{ 

     xtype: 'fieldset', 
     title: 'Information & Appointment', 
    }, 
    { 
     xtype: 'selectfield', 
     id: 'request', 
     label: 'You need', 
     options: [ 
     { 
      text: 'Appointment', 
      value: 'Appointment' 
     }, 
     { 
      text: 'Information', 
      value: 'Information', 

     }] 



    }, 
    { 
xtype: "datepickerfield", 
id: "startDate", 
label: "when", 
picker: { yearFrom: 2012, yearTo: 2020} 

    },}] 
    }] 
    }); 
    Ext.reg('Bankingrendezvous', App.views.Bankingrendezvous); 

당신을 감사합니다 "datepickerfield를"나는 위해 xtype 표시 만들고 싶어. 나는 당신이 말하는대로 시도했다 :

{ 
xtype: "datepickerfield", 
id: "startDate", 
label: "when", 
picker: { yearFrom: 2012, yearTo: 2020} 
    this.items.getAt().hide(); 
}, 

그러나 그것은 작동하지 않는다.


items: [{ 
xtype: 'formpanel', 
id: 'form', 
fullscreen: true, 
scroll: 'vertical', 
items: [{ 

     xtype: 'fieldset', 
     title: 'Information & Appointment', 
    }, 
    { 
     xtype: 'selectfield', 
     id: 'request', 
     label: 'You need', 
     options: [ 
     { 
      text: 'Appointment', 
      value: 'Appointment' 
     }, 
     { 
      text: 'Information', 
      value: 'Information', 
     }], 
    listeners: { 
     function() 
        { 
        if (Ext.getCmp('request').getValue() == 'Information') 
         { 
         Ext.getCmp('startDate').hide(); 
         } 
        } 
       }, 


    }, 
    { 
xtype: "datepickerfield", 
id: 'startDate', 
label: "when", 
picker: { yearFrom: 2012, yearTo: 2020},   
     }, 

내가이 시도하지만

답변

4

당신은 두 가지 방법 중 하나를 사용할 수 있습니다 작동 나던 : hide()/show() 또는 setVisible(true/false).

클래스에서 요소를 액세스를 설정하기 위해
this.items.getAt(<index of item>).hide(); 
this.items.getAt(<index of item>).show(); 

당신이 그것을 할 :

(예를 들어, initComponent 함수() 이벤트 내부), 다음 절을 사용하여 객체의 내부 항목에 액세스하려면

getCmp() 메서드를 사용하여 :

var el = Ext.getCmp("elementID"); 

다음 항목에 액세스하고 가시성을 설정하십시오.

el.items.getAt(<index of item>).setVisible(false); // hide 
el.items.getAt(<index of item>).setVisible(true); // show