如何在表单提交中获取Ext.SegmentedButton值?
{
xtype: 'segmentedbutton',
name: 'title',
items: [
{text: 'Mr', value: 'Mr'},
{text: 'Mrs', value: 'Mrs'},
{text: 'Madam', value: 'Madam'},
{text: 'Ms', value: 'Ms'},
{text: 'Dr', value: 'Dr'},
{text: 'Prof', value: 'Prof'},
],
},
最佳答案
如果您引用了分段按钮,则you can just query it for elements that are pressed
segmented.down('[pressed=true]');
完整示例https://fiddle.sencha.com/#fiddle/ctk
var segmented = Ext.widget({
xtype: 'segmentedbutton',
name: 'title',
items: [
{text: 'Mr', value: 'Mr'},
{text: 'Mrs', value: 'Mrs'},
{text: 'Madam', value: 'Madam'},
{text: 'Ms', value: 'Ms'}
],
});
var container = Ext.create('Ext.panel.Panel', {
width: 400,
renderTo: Ext.getBody(),
buttons: [{
text: 'Get Selected',
handler: function() {
var selectedBtn = segmented.down('[pressed=true]');
alert(selectedBtn && selectedBtn.value);
}
}],
items: segmented
});