在 TextField 之后显示文本的最佳方式是什么? [英] What is the best way to display text just after a TextField?
问题描述
我正在创建一个表单面板,其中包含通过 xtype 创建的项目(不是为每个项目调用 new).我想在 TextField 的右侧添加一个精度.
I'm creating a formpanel with items created via xtype (not calling new for each items). I'd like to add a precision at the right of the TextField.
我设法通过设置包含 TextField + 标准面板的 CompositeField 来做到这一点,但是有没有更好的方法,例如我会错过的 TextField 中的属性或更好的替代方法?
I managed to do it by setting a CompositeField containing the TextField + a standard Panel, but is there a better way, like a property in the TextField I would have missed or a better alternative ?
感谢您的帮助!:)
new Ext.form.FormPanel ({
'id': 'create-form',
'header': true,
'headerAsText': true,
'hideCollapseTool': true,
'title': 'New Component',
'width': 550,
'style': 'margin: 100px auto',
'labelWidth': 200,
'items': [
{
'items': [
{
'xtype': 'textfield',
'fieldLabel': 'Duration (in hours)',
'name': 'name'
}
]
}
]
});
推荐答案
如果你只需要一个字段,一个 CompositeField
就可以了.但是,您真的需要一个全新的 Panel
文本吗?普通的 Label
还不够吗?
If you need it for one field only, a CompositeField
is fine. However, do you really need a whole new Panel
for the text - wouldn't a regular Label
suffice?
如果您需要更可重用的解决方案,请查看 FormLayout.您可以修改模板并在字段后添加一个特殊部分,在其中显示附加信息.
If you need a more reusable solution, have a look at the fieldTpl
config option of FormLayout. You could modify the template and add a special section after the field, in which to display the additional information.
这篇关于在 TextField 之后显示文本的最佳方式是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!