слушатель радиопереключателя - PullRequest
2 голосов
/ 11 января 2012

Я хочу добавить 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});

Я просто не могу заставить его работать.Любой совет / помощь?

Спасибо

1 Ответ

7 голосов
/ 11 января 2012

Попробуйте это:

{   
    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
            }
        }
    }
}
...