2

I am newbie in Sencha Touch and I have a "segmentedButton" component, and I need to get the button pressed depending the user interaction in the controller.

Help please!!

2 Answers 2

4

You can use the getPressedButtons() method.

Example:

Ext.application({
    name : 'Fiddle',

    launch : function() {
        var segmentedButton = Ext.create('Ext.SegmentedButton', {
            allowMultiple: true,
            items: [{
                text: 'Option 1'
            },{
                text: 'Option 2',
                pressed: true
            },{
                text: 'Option 3'
            }],
            listeners: {
                toggle: function(container, button, pressed){
                    alert("User toggled the '" + button.getText() + "' button: " + (pressed ? 'on' : 'off'));
                    console.log(container.getPressedButtons());
                }
            }
        });
        Ext.Viewport.add({ xtype: 'container', padding: 10, items: [segmentedButton] });
    }
});
3
  • Ok, with the method "getPressedButtons()" and getItemId() I can evaluate different behaviour for each button. Thanks for your help.
    – inane
    Commented Dec 8, 2014 at 17:21
  • Hi Inane, if the solution worked you should mark this as answered. Thanks! Commented Dec 9, 2014 at 15:40
  • Thanks @GuilhermeLopes with your clue it was useful for me!! :-)
    – inane
    Commented Dec 9, 2014 at 18:06
0

If anyone is looking for the same for Ext Classic here is the solution.

To get the values use container.getValue().

To set the values use container.setValue().

Fiddle is here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.