extjs - 如何在 ExtJS 中对表单面板字段进行顶部对齐和自动换行?

标签 extjs word-wrap formpanel

如何使多行表单字段描述自动换行顶部对齐其文本?

alt text

<script type="text/javascript">
    clearExtjsComponent(regionContent);
    var panel_form = new Ext.FormPanel({
        labelWidth: 100,
        frame:true,
        style: 'margin: 10px',
        title: 'Test Product ID#2',
        bodyStyle:'padding:5px 5px 0',
        width: 500,
        defaultType: 'textfield',

        items: [{
                fieldLabel: 'ID',
                value: '2',
                name: 'id',
                disabled: true,
                width: 370,
                style: 'text-align: right',
                name: 'id',
                disabled: true,
                width: 50,
            },{
                fieldLabel: 'Product',
                value: 'Envelope',
                name: 'product',
                width: 370,
            },{
                fieldLabel: 'Description',
                value: 'Having a good idea about the functional requirements and client-side technology choices, the next step was to decide how things were going to be on the server side. To channel all communications with my web client I decided to use an http handler. For the articles repository, a binary file would go very well with my simplicity and short-construction-time requirements. Any data access and business logic would be placed inside class libraries.',
                name: 'description',
                width: 370,
                height: 100,
            },{
                    ...

当我尝试 xtype: 'textArea' 时,出现错误 types[config.xtype || defaultType] 不是构造函数:

        },{
            fieldLabel: 'Description',
            value: 'Having a good idea about the functional requirements and client-side technology choices, the next step was to decide how things were going to be on the server side. To channel all communications with my web client I decided to use an http handler. For the articles repository, a binary file would go very well with my simplicity and short-construction-time requirements. Any data access and business logic would be placed inside class libraries.',
            height: 100,
            xtype: 'textArea',
            name: 'description',
            width: 370,
        },{

最佳答案

您将 defaultType 更改为 'textfield',这是您要在除“说明”字段之外的所有字段上使用的 xtype。对于该字段,您需要 xtype'textarea'。这将像典型的 html 文本区域一样自动顶部对齐文本和自动换行。请记住,对于大量文本,您可能会在文本区域中看到滚动条。如果您想避免滚动条,请查看 TextArea 配置选项 growgrowMaxgrowMin

示例:

   {
       xtype: 'textarea',
       fieldLabel: 'Description',
       value: 'Having a good idea about the functional requirements and client-side technology choices, the next step was to decide how things were going to be on the server side. To channel all communications with my web client I decided to use an http handler. For the articles repository, a binary file would go very well with my simplicity and short-construction-time requirements. Any data access and business logic would be placed inside class libraries.',
       name: 'description',
       width: 370,
       height: 100,
    }

关于extjs - 如何在 ExtJS 中对表单面板字段进行顶部对齐和自动换行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4471868/

相关文章:

forms - 无法在容器面板初始化时在 Ext Js FormPanel 上调用 getValues()

database - GWT 和 notifyAll() (java.lang.Object)

javascript - extjs4 中的 getActionEl() 实际上返回什么?

javascript - 与桌面浏览器兼容的 HTML5 移动框架

editor - Sublime Text 3 自动换行(设置为默认)不再工作

html - 断字 : break-word failing inside pre tag

javascript - 首次单击当前编辑行中的组合框时,Ext 4 RowEditor 编辑取消

extjs - 如何使用 Compass/Saas 在 Extjs 中自定义工具栏按钮?

html - 带有背景图像的文本换行

javascript - 当工具栏存在时,Ext js FormPanel 不显示面板项目