Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: setBlankText

  1. #1
    Sencha User
    Join Date
    May 2008
    Posts
    13
    Vote Rating
    0
      0  

    Default setBlankText

    Hi,

    In gxt2.x on Fields there was a method ....getMessages().setBlankText()

    How to change the default text in gxt3?

    Marcel

  2. #2
    Sencha Premium Member
    Join Date
    Sep 2007
    Posts
    13,976
    Answers
    60
    Vote Rating
    131
      0  

    Default

    You are probably looking for setEmptyText.

  3. #3
    Sencha User
    Join Date
    May 2008
    Posts
    13
    Vote Rating
    0
      0  

    Default

    No. That is the text thats displayed in the field it self.
    I want to change the text which is displayed when you validated the field.
    Now it will display 'This field is required'

  4. #4
    Sencha Premium Member
    Join Date
    Sep 2007
    Posts
    13,976
    Answers
    60
    Vote Rating
    131
      0  

    Default

    That is comming from the EmptyValidator. Instead of setting setAllowBlank on the field, initiate the EmptyValidator directly with the EmptyMessages implementation of your needs

  5. #5
    Sencha User
    Join Date
    May 2008
    Posts
    13
    Vote Rating
    0
      0  

    Default

    Could you please give me a sample how to use it?

  6. #6
    Sencha Premium Member
    Join Date
    Sep 2007
    Posts
    13,976
    Answers
    60
    Vote Rating
    131
      0  

    Default

    Code:
    EmptyValidator<String> myValidator = new EmptyValidator<String>();
    myValidator.setMessages(new EmptyMessages() {
    @Override
        public String blankText() {
          return "your text";
        }
    });
    myField.addValidator(myValidator);

  7. #7
    Sencha User
    Join Date
    May 2008
    Posts
    13
    Vote Rating
    0
      0  

    Default

    I tried it on a combobox, but it doesn't work, still get the messagae 'This field is required'.

    ComboBox<Provider> combo = new ComboBox<Provider>(providerList, props.display());

    EmptyValidator<Provider> myValidator = new EmptyValidator<Provider>();
    myValidator.setMessages(new EmptyMessages() {
    @Override
    public String blankText() {
    return "your text";
    }
    });
    combo.addValidator(myValidator);

  8. #8
    Sencha Premium Member
    Join Date
    Sep 2007
    Posts
    13,976
    Answers
    60
    Vote Rating
    131
      0  

    Default

    Did you enable allowblank on the field?

  9. #9
    Sencha User
    Join Date
    May 2008
    Posts
    13
    Vote Rating
    0
      0  

    Default

    if I do that it works.

    But I don't want to allow blank, its contradictory.
    In gxt2 I used setAllowBlank(false)....

  10. #10
    Sencha Premium Member
    Join Date
    Sep 2007
    Posts
    13,976
    Answers
    60
    Vote Rating
    131
      0  

    Default

    Have you looked at the code what setAllowBlank is actually doing? It just sets up the validator (which you are doing manually now) and sets the same property on the cell (which you are missing right now, but should only be relevant for a ComboBox).

    You are not allowing blank, that is why you are setting the validator.

Page 1 of 2 12 LastLast

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •