3

今回の課題は、アイテムを出現させたり消滅させたりすることです。私はそれが行われていることを知っていますがhide()show()方法がわかりませんか? これが私のコードです。「selectfield」で「Appointment」を選択すると、「datepickerfield」というxtypeを表示させたい

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);

ありがとうございました。私はあなたが言うように試しました:

  {
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

1 に答える 1

5

hide()/show()またはの 2 つの方法のいずれかを使用できますsetVisible(true/false)

オブジェクト内 (たとえば、initComponent() イベント内) のアイテムにアクセスする場合は、次の句を使用します。

this.items.getAt(<index of item>).hide();
this.items.getAt(<index of item>).show();

クラス外の要素へのアクセスを設定するには、getCmp() メソッドを使用して行います。

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

次に、アイテムにアクセスして可視性を設定します。

el.items.getAt(<index of item>).setVisible(false); // hide
el.items.getAt(<index of item>).setVisible(true); // show 
于 2012-03-15T08:10:00.177 に答える