PDA

View Full Version : [FIXED] setPressed() should work for itemId?



johnnywengluu
3 Nov 2011, 6:46 AM
When using segmentedButton.setPressed() I have to pass an "id". When passing an "itemId" it doesn't work.

I believe it should?


var panel = Ext.create('Ext.Panel', {
fullscreen : true,
items : [
{
xtype : 'segmentedbutton',
items : [
{
text : 'One',
itemId : 'one'
},
{
text : 'Two',
itemId : 'two'
},
{
text : 'Three',
itemId : 'three'
}
]
}
]
});

mitchellsimoens
3 Nov 2011, 8:36 AM
setPressed is marked as deprecated. Please use setPressedButtons and pass an array of buttons

johnnywengluu
3 Nov 2011, 8:52 AM
Right.

The same issue remains though. I have to use an "id" on the button. It doesn't work on "itemId".

mitchellsimoens
3 Nov 2011, 8:53 AM
You should be able to pass in button instances correct? Does that at least work? Narrowing down what change needs to be done.

johnnywengluu
3 Nov 2011, 8:57 AM
I don't have the button instance available. The buttons are in the views, I am trying to have a button pressed from the controller.

I'm just reacting to that it works for "id" but not "itemId". Feels weird since I rather want to use "itemId".

"id" should only be used if that button is unique in the whole app.

johnnywengluu
3 Nov 2011, 7:56 PM
It's definitely something wrong with segmentedbutton.

Whenever I set an "itemId" on a button within it it stops working properly. You cannot click on the button with an "itemId" set.

Clearly a bug.

mitchellsimoens
4 Nov 2011, 4:24 AM
Looks like in the Ext.SegmentedButton code, the applyPressedButtons does a getComponent call to make sure the component being passed is a component and not a string. It then goes through and gets the itemId or if that isn't present, then the id. It takes that value and looks at the items MixedCollection and looks at the map Object which has id (not itemId) as the key and the button as the value. But since getComponent choose to use itemId, it cannot find the key, this is where it breaks.

Will report this right on up!

rdougan
7 Nov 2011, 11:26 AM
This was an issue with Container.getComponent. the items collection in container was not using the ItemId for the map, if it was specified, so it never found it using itemId.