2012-01-11 70 views
2

我想在工具栏上添加3个单选按钮这样的:监听单选

dockedItems: [ 
      { 
       xtype: 'toolbar', 
       dock: 'top', 
       items: [ 
        { 
         xtype: 'radiogroup', 
         width: 500, 
         fieldLabel: 'Show', 
         items: [ 
          { 
           xtype: 'radiofield', 
           id: 'all', 
           name: 'show', 
           boxLabel: 'All vehicles', 
           checked: true 
          }, 
          { 
           xtype: 'radiofield', 
           id: 'online', 
           name: 'show', 
           boxLabel: 'Online vehicles' 
          }, 
          { 
           xtype: 'radiofield', 
           id: 'offline', 
           name: 'show', 
           boxLabel: 'Offline vehicles' 
          } 
         ] 
        } 
       ] 
      } 
     ] 

我想用一个侦听这些按钮。当有人点击离线我想加载internals.load({url:internals/offline.json});

我只是不能得到它的工作。任何建议/帮助?

感谢

回答

6

试试这个:

{ 
    xtype: 'radiogroup', 
    width: 500, 
    fieldLabel: 'Show', 
    items: [ 
     { 
      xtype: 'radiofield', 
      id: 'all', 
      name: 'show', 
      boxLabel: 'All vehicles', 
      checked: true, 
      inputValue: 'all' 
     }, 
     { 
      xtype: 'radiofield', 
      id: 'online', 
      name: 'show', 
      boxLabel: 'Online vehicles', 
      inputValue: 'online' 
     }, 
     { 
      xtype: 'radiofield', 
      id: 'offline', 
      name: 'show', 
      boxLabel: 'Offline vehicles', 
      inputValue: 'offline' 
     } 
    ], 
    listeners: { 
     change: function(field, newValue, oldValue) { 
      var value = newValue.show; 
      if (Ext.isArray(value)) { 
       return; 
      } 
      if (value == 'offline') { 
       // do something 
      } 
     } 
    } 
} 
+0

感谢的作品完美! – 2012-01-12 07:43:39