Search code examples
extjsgwtgxt

Setting maxLength when using Sencha GXT


I am using Sencha GXT 3.1.1 to use it with GWT. Now I should limit the size of TextFields by using the maxLength attribute of HTML.

First of all, I haven't found any possibility to do that directly in this class, with setMaxLength() method.

Can anybody help how to use the maxlength attribute inside Sencha GXT classes?


Solution

  • There is a way, but it's a bit of a hack:

    textField.getCell()
        .getAppearance()
        .getInputElement(textField.getElement())
        .setAttribute("maxLength", "3");