选择特定单选按钮时如何显示卡布局面板

时间:2017-10-03 15:44:39

标签: extjs

 var radioGroup = {
                xtype: 'radiogroup',
                layout: 'hbox',
                width: 800,
               items: [{
                  boxLabel: 'Select Time Interval',
                  name: 'timeInterval',
                  id: 'selectTimeInterval',
                  inputValue: 'timeSelector',
                  checked: 'true',
                  handler: function() {
                      //Ext.getCmp('PanelID').layout.setActiveItem('timeIntervalPanel');
                      PanelID.setActiveItem('timeIntervalPanel');
                  }
               },
               {
                  boxLabel: 'Specific Interval',
                  name: 'timeInterval',
                  id: 'specificTimeInterval',
                  inputValue: 'specificInterval',
                  handler: function() {
                      //Ext.getCmp('PanelID').layout.setActiveItem('card-2');
                      PanelID.setActiveItem('card-2');
                  }


               },{

                   boxLabel: 'Last Measurement Collected',
                   name: 'timeInterval',
                   id: 'LastMeasurementCollected',
                   inputValue: 'lastMeasuremnet'

               }]

            };


             var cardPanel = Ext.create('Ext.panel.Panel', {
                 layout: 'card',
                 id: 'PanelID',
                 activeItem: 0,
                 items: [ {
                     itemId: 'timeIntervalPanel',
                     name: 'timeInterval',
                     xtype: 'optima-timeintervalpanel',
                     text: 'select',
                     endDate: new Date(),
                     startDate: Ext.Date.add(new Date(), Ext.Date.DAY, - 30)
                    },
                     {
                         itemId: 'card-2',
                         html: 'hello2'
                     }
                     ]
             });

2 个答案:

答案 0 :(得分:1)

如果您想使用绑定来执行此操作,请参阅docs以获取对RadioGroup的绑定。

以下是您编辑的代码段,用于显示单选按钮选择中的一个面板:

items: [{
            xtype: 'radiogroup',
            layout: 'hbox',
            width: 800,
            bind: {
                value: '{selectedValue}'
            },
            items: [{
                boxLabel: 'Select Time Interval',
                name: 'timeInterval',
                inputValue: 'timeSelector',
                checked: 'true',
            }, {
                boxLabel: 'Specific Interval',
                name: 'timeInterval',
                id: 'specificTimeInterval',
                inputValue: 'specificInterval',
            }, {

                boxLabel: 'Last Measurement Collected',
                name: 'timeInterval',
                id: 'LastMeasurementCollected',
                inputValue: 'lastMeasuremnet'
            }],
        }, {
            xtype: 'panel',
            layout: 'card',
            bind: {
                activeItem: '{selectedValue.timeInterval}'
            },
            items: [{
                itemId: 'timeSelector',
                name: 'timeInterval',
                xtype: 'datepicker',
                fieldLabel: 'select',
                endDate: new Date(),
                startDate: Ext.Date.add(new Date(), Ext.Date.DAY, -30)
            }, {
                itemId: 'specificInterval',
                html: 'hello2'
            }, {
                itemId: 'lastMeasuremnet',
                html: 'hello3'
            }]
        }]

检查工作Fiddle

答案 1 :(得分:0)

您需要切换可以使用以下代码完成的更改事件的布局。 listeners: { change: function() { Ext.getCmp('PanelID').getLayout().setActiveItem(1); } }

我已在此fiddle

中更新了您的代码