1

コンボからリスナーを使用して ext.js (xtype:"compositefield") を表示/非表示にしようとしています。複合フィールドのラベルが非表示にならないことを除いて、すべてがうまく機能します。.hide()/.show() を使用できるように、複合フィールド DOM 要素全体を選択するにはどうすればよいですか?

複合フィールドのコード:

xtype: 'compositefield',
                   labelStyle: 'width: 60px',
                   fieldLabel: 'Player 1',
                   id: "player_1_fields",
                   msgTarget: 'under',
                   items:[
                       {xtype: 'displayfield', value: 'Name',margins: '3 5 0 22'},
                       {xtype: 'textfield', name: 'props_name_1', width: 135},
                       {xtype: 'displayfield', value: 'Score',margins: '3 5 0 0'},
                       {xtype: 'numberfield', name: 'props_score_n1', width: 35}
                   ]

リスナーのコード:

listeners: {
                                    select: function(combo, record, index) {
                                     if ( combo.getValue() == "2" ) 
                                                {
                                                Ext.getCmp("player_1_fields").getEl().hide();

                                                }
                                            else
                                                {
                                                Ext.getCmp("player_1_fields").getEl().show();

                                                }
                                    }
                                  }
4

1 に答える 1

2

このコードを試してください:

select: function(combo, record, index) {
    if ( combo.getValue() == "2" ) {
            Ext.getCmp("player_1_fields").getEl().up('.x-form-composite').hide();
    } else {
            Ext.getCmp("player_1_fields").getEl().up('.x-form-composite').show();
    }
}

Up は、特定のクラスを持つ親を見つける必要があります (フォーム項目全体の ExtJs クラスにする必要があります)。

于 2012-10-04T08:54:43.857 に答える