Code:
items: [{
xtype: 'segmentedbutton',
disabled: true,
//id:'segmentWidget',
items: [
{
text: 'text1',
flex: 1,
},
{
text: 'text2',
flex: 1
},
{
text: 'text2',
flex: 1
}
]
}]
Ext.getCmp('segmentWidget').setPressedButtons(0);
How can i do this without using ID
Thanks
If you don't want to use
idto select components in Sencha (and it is a good idea to do that when possible to keep things reusable and avoiding polluting the global ids space) you have several options.(bold part is taken from Sencha docs, the rest is mine)
Ext.Container.getComponent()method: Examines this container's items property and gets a direct child component of this container. Basically you pass in a string which should match theidoritemIdproperty of one of theitemsin that container.Ext.Container.query()method: Retrieves all descendant components which match the passed selector. Executes an Ext.ComponentQuery.query using this container as its root. This returns an array ofExt.Component. Take a look atExt.ComponentQuery.querydocs to understand which queries you can do. In short, you can simply select byxtype, in your case you can do:fatherComponent.query('segmentedbutton')[0], or by another property, for example:fatherComponent.query('[text=text1]')[0]Ext.Component.up()method: Walks up the ownerCt axis looking for an ancestor Container which matches the passed simple selector.