2
关注
1364
浏览

如何使用setActiveItem进行卡片布局以基于radiobuttton选择显示面板?

为什么被折叠? 0 个回复被折叠
woniujie 未验证用户 用户来自于: 广东省
2020-09-16 13:23

您需要使用以下步骤: -

  • 首先,你需要得到您已在change事件RadioGroup提供layout:"card"组件。
  • 现在,您需要获得组件的getLayout()
  • 现在需要使用setActiveItem(newItem)方法card布局组件。

在这种FIDDLE,我已经创建使用你的代码演示并提出一些修改。我希望这能帮到您。

代码段

//Timeinterval panel 
Ext.define('Timeintervalpanel', { 
    extend: 'Ext.panel.Panel', 
    xtype: 'timeintervalpanel', 
    html: 'This is timeintervalpanel' 
}); 

//Specific Interval panel 
Ext.define('SpecificInterval', { 
    extend: 'Ext.panel.Panel', 
    xtype: 'specificinterval', 
    html: 'This is specificinterval' 
}); 

//Empty Panel 
Ext.define('EmptyPanel', { 
    extend: 'Ext.panel.Panel', 
    xtype: 'emptyPanel', 
    html: 'This is emptyPanel' 
}); 

//Panel with radio button and card item. 
Ext.create('Ext.panel.Panel', { 
    title: 'Card Layout Example with radio buttons', 
    renderTo: Ext.getBody(), 
    height: window.innerHeight, 
    layout: 'vbox', 
    tbar: [{ 
     xtype: 'radiogroup', 
     itemId: 'radioButton', 
     layout: 'hbox', 
     defaults: { 
      flex: 1, 
      margin: 5, 
      name: 'timeInterval' 
     }, 
     items: [{ 
      boxLabel: 'Timeinterval panel', 
      inputValue: 0, 
      checked: true 
     }, { 
      boxLabel: 'Specific Interval', 
      inputValue: 1 
     }, { 
      boxLabel: 'Empty Panel', 
      inputValue: 2 
     }], 
     listeners: { 
      change: function (radio, newValue, oldValue) { 
       var cardPanel = radio.up('panel').down('#PanelID').getLayout(); 

       cardPanel.setActiveItem(newValue.timeInterval); 

       //Only just for animation 
       //activeItem.getEl().slideIn('r'); 
      } 
     } 
    }], 
    items: [{ 
     //This panel have provided card layout. 
     xtype: 'panel', 
     flex: 1, 
     width: '100%', 
     layout: 'card', 
     itemId: 'PanelID', 
     defaults: { 
      bodyPadding: 20 
     }, 
     items: [{ 
      xtype: 'timeintervalpanel' 
     }, { 
      xtype: 'specificinterval' 
     }, { 
      xtype: 'emptyPanel' 
     }] 
    }] 
}); 

关于作者

问题动态

发布时间
2020-09-15 15:51
更新时间
2022-09-15 15:51
关注人数
2 人关注

相关问题

个人工作笔记 Powered BY WeCenter V4.1.0 © 2024 粤ICP备2020123311号