【问题标题】:Limit the number of lines entered in ExtJS Textarea限制在 ExtJS Textarea 中输入的行数
【发布时间】:2014-07-03 15:01:01
【问题描述】:

检查此fiddle。我们如何限制允许在 ExtJS TextArea 中输入的行数。 ExtJs 是否提供了开箱即用的东西,或者我必须回复一些 cusotm 函数,如link 中所示

我正在使用 ExtJs 4.1

Ext.onReady(function () {
    Ext.create('Ext.window.Window', {
        height: 60,
        layout: 'anchor',
        minHeight: 60,
        width: 200,
        items: [{

            grow: true,
            anchor: '100%',
            flex: 1,
            xtype: 'textareafield'
        }]
    }).show();
});

【问题讨论】:

    标签: javascript jquery extjs extjs4.1 lodash


    【解决方案1】:

    您可以将maxLengthenforceMaxLength 属性一起使用:

    Ext.onReady(function () {
        Ext.create('Ext.window.Window', {
            height: 60,
            layout: 'anchor',
            minHeight: 60,
            width: 200,
            items: [{
                grow: true,
                anchor: '100%',
                flex: 1,
                xtype: 'textareafield',
                maxLength: 5, // 5 is only used for demo purpose
                enforceMaxLength: true
            }]
        }).show();
    });
    

    Updated Fiddle

    【讨论】:

    • 限制允许输入的字符数,但不限制允许输入的行数。
    • 那你需要写一个自定义函数。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多