Reputation: 23
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?
Upvotes: 1
Views: 576
Reputation: 11
You can also do the following:
InputElement inputElement = textField.getElement()
.select("input")
.getItem(0)
.cast();
inputElement.setMaxLength(valueMaxLength);
Upvotes: 1
Reputation: 511
There is a way, but it's a bit of a hack:
textField.getCell()
.getAppearance()
.getInputElement(textField.getElement())
.setAttribute("maxLength", "3");
Upvotes: 0
Reputation: 3832
I think the best way to solve this problem is using a validator.
myTextField.addValidator(new MaxLengthValidator(3));
This validator will check if the value of the TextField has more than three letters. If it has more than three letters it will show an error.
Upvotes: 0