Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    How to allow only numbers in ListGridField ?

    Hi,

    I dynamically created ListGrid in smart GWT. All the ListGridFields are accepting any character but I want to allow only numbers in some ListGridField.
    I tried :-
    1) ListGridField gridField = new ListGridField("columnName", "columnTitle");
    gridField.setType(ListGridFieldType.INTEGER);
    2 ) ListGridField gridField = new ListGridField("columnName", "columnTitle");
    IntegerRangeValidator integerRangeValidator = new IntegerRangeValidator();
    integerRangeValidator.setMin(0);
    integerRangeValidator.setMax(99);
    gridField.setValidators(integerRangeValidator);
    But, still it allow any character.

    Please reply if you know how could I fixed this ?

    #2
    The type being set to Integer, and the integer range validator will ensure that when validation occurs, invalid (non numeric) values are rejected. This is definitely a good idea to avoid invalid values being submitted to the server (or accepted on the server from a request that doesn't go through client side validation for some reason).
    *Edit: Note that the server validation will only be respected for validators applied to the dataSource configuration (ds.xml file) - as the server of course doesn't see the ListGridField definition directly.

    If you also want to limit the user input, you can use a mask or keypress filter

    Comment

    Working...
    X