Announcement

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

    Editable TextItem with enabled setMask()

    Hello, all

    I use SmartGWT 6.1. My task is very simple: I need create TextItem with mask. Method setMask() works fine for empty form. But when I call it on TextItem with value, then it clears value of TextItem.

    How to create TextItem with filled value (not empty) and with mask ?

    For example:

    TextItem tx = new TextItem();
    ....
    tx.setValue("ТС RU Д-CN.АБ12.В.12345");
    ...
    tx.setMask(">ТС RU Д\\-[A-Z][A-Z].[А-Я][А-Я]##.[А-В].#####"); // Clears value, but user should see value and can edit it.

    Best regards,
    Eugeny
    Last edited by c0ff75; 11 Mar 2018, 07:37.

    #2
    I found workaround for my case:
    1. save value of TextItem before call setMask()
    2. call setMask()
    3. call setMaskOverwriteMode(true)
    4. restore value of TextItem with setValue()

    But still it looks strange

    Comment


      #3
      Dynamically changing the mask after an item has already been created and drawn clears the value because we don't know if the value matches the mask, and figuring that out would require a completely different set of code from the code used for character-by-character input.

      This is normally not a problem, as the natural flow of code is that the mask is established before the value. But if you have a special case where the mask changes on-the-fly, yes you have to restore the value as you've shown.

      Comment

      Working...
      X