1

I am trying to force a textfield to convert whatever you enter to uppercase. This is the line that I have been using

style: 'text-transform: uppercase'

It is working on 90% of my textfield however for one specific textfield, it will not work. It converts whatever you type into a textfield, but then when you tab out of the textfield it reverts back to lowercase for some reason.

here is the full code for the textfield:

    {
    id: 'conditionValue',
    header: "Condition Value",
    dataIndex: 'condValue',
    width: 100,
    editor: newExt.form.TextField({
        style: 'text-transform: uppercase'
    }
})
}
4

3 回答 3

3

你可以在不需要 jQuery 的情况下做到这一点,而是直接在 Ext JS 中:

{
    id: 'conditionValue',
    header: "Condition Value",
    dataIndex: 'condValue',
    width: 100,
    editor: newExt.form.TextField({
        listeners:{
           change:function(field){
                field.setValue(field.getValue().toUpperCase());
           }
        }
    })
}

也就是说,在 ExtJS 中执行此操作的最佳方法是使用fieldStyle,例如在您的 texfield 上:

fieldStyle: 'text-transform:uppercase'

而不是您当前设置的位置style

看到这个小提琴

于 2013-11-12T16:19:53.840 回答
1

尝试设置文本字段的fieldStyle(自 ExtJS 4.0 起可用),然后处理其change事件。

id: 'conditionValue',
header: "Condition Value",
dataIndex: 'condValue',
width: 100,
editor: newExt.form.TextField({
    fieldStyle: 'text-transform:uppercase;',
    listeners: {
       change: function(field, newValue, oldValue) {
           field.setValue(newValue.toUpperCase());
       }
    }
}
于 2013-11-13T10:31:26.417 回答
0

原因是,一旦您将注意力移出文本字段,该字段本身就会被隐藏,并且其内容会被复制到表格单元格(有点,实际上它通过记录和列渲染器传递)。将相同的CSS 样式添加到列中,这样就可以了。如果这还不够,请自定义列renderer

于 2013-11-12T15:20:56.297 回答