Reputation: 648
I am working in a Sencha Touch application and I need to create a dynamic segmented button with different number of items from the controller instead of add to the view each time this component.
Correct way for this It should be create a singleton class and call to this when you need create the component... right?
Thank you..
Upvotes: 0
Views: 468
Reputation: 74166
You can use setItems
:
Sets the value of items.
For example:
segmentedButton.setItems([{text: 'Option 4'}, {text: 'Option 5'}])
Working example: https://fiddle.sencha.com/#fiddle/1035
Upvotes: 1
Reputation: 50
Give id to button in view:
{
xtype: 'segmentedbutton',
allowToggle: false,
layout: {
type: 'hbox',
align: 'end'
},
items: [
{
xtype: 'button',
id: 'btnStudents',
text: 'student'
},
{
xtype: 'button',
id: 'btnTeacher',
text: 'teacehr'
}
]
}
then in controller:
refs: {
btnStudents: 'button#btnStudents',
btnTeacher: 'button#btnTeacher',
},
and depending on your requirement you can use:
this.getBtnStudents().show();
or this.getBtnStudents().hide();
Upvotes: 0