我有一个表单,末尾有一个按钮,如下所示:
var simple_form_right = new Ext.FormPanel({
frame:true,
labelWidth: 90,
labelAlign: 'right',
title: 'Orderer Information',
bodyStyle:'padding:5px 5px 0',
width: 300,
height: 600,
autoScroll: true,
itemCls: 'form_row',
defaultType: 'displayfield',
items: [{
fieldLabel: 'Customer Type',
name: 'customerType',
allowBlank:false,
value: 'Company'
}, .... {
fieldLabel: 'Item 21',
name: 'item21',
value: 'test'
},
new Ext.Button({
text: "Cancel Order",
style: 'width: 100%; color: red',
handler: function() {
alert('pressed');
}
})
]
});
该按钮有效,但正如样式信息尝试所示,我希望该按钮扩展到整个表单并具有红色文本。
如何使按钮的宽度延伸到整个表单并在按钮内显示红色文本?
附录
罗比的解决方案 100% 有效:
...
}, {
fieldLabel: 'Item 20',
name: 'item20',
value: 'test'
}, {
fieldLabel: 'Item 21',
name: 'item21',
value: 'test'
}, {
xtype: 'button',
text: '<span style="color:red">Cancel Order</span>',
anchor: '100%',
handler: function() {
alert('pressed');
}
}
最佳答案
将您的按钮定义更改为。
{
xtype: 'button',
text: '<span style="color:red;">Cancel Order</span>',
anchor: '100%'
handler: function() { alert('pressed') };
}
要使 anchor 属性起作用,您的按钮不能位于面板的“按钮”数组中。
关于javascript - 如何使 Ext.FormPanel 中的按钮 width=100% 并带有红色文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5144391/