Announcement

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

    EditorValueFormatter

    I think I am missing something here, and I'm hoping you can quickly point me in the right direction.

    I have some simple number formatters


    I have a few FormItems I want to use these

    So I use my form to edit a new record, I manually enter a value into one of the FormItems, I then move to the next FormItem...at this point I would expect to see my value formatted, but much to my dismay the value disappears. The values are technically there, as I can save the form and see them get saved, and display the record via the same form...and the the fields are formatted as I would have expected to begin with. I have searched your forums, and since no one else has mentioned this issue...I'm inclined to think I'm missing a step?
    Last edited by jpappalardo; 24 Sep 2014, 09:33.

    #2
    When applying a formatter to a freeform text entry field you're expected to also apply a complimentary parser.
    Essentially the formatter / parser pair should be able to round-trip a value from display value (string) to stored data value (in your case a numeric value), and back again.

    This would give you the behavior where a user could enter a (formatted) string and it would be stored as an integer, and displayed correctly.
    You can also write your parser function to accept additional formats (say a simple string of unformatted numbers) and parse them correctly into the data type value you want to store. In this case you should see the parser convert the user entered value to an integer (for storage), and re-format to your desired display format for display (and further editing).

    Note that you'll probably also want to set changeOnKeypress to false - you probably don't want the value to be being refomatted as the user types, just when the user tabs out of the field.

    Let us know if you can't get this working for any reason.

    Comment


      #3
      Thank you, that got normal text entry working for me.

      However, I do have another issue. We provide a few mechanisms for populating fields via what we are calling "presets" that are stored in other tables. If there is a preset marked as a default preset, then when editing a new record those values are pulled from the ds, and set on the valuesManager backing the dynamic forms. Also we provide a picker which brings up a dialog displaying all presets and allows the user to select one. Again the values from the selected record are set on the valuesmanager.

      Ultimately, the code is rather simple


      For some reason the values do not appear in the form.
      Although I never disable auto synchronization, I did try calling ValuesManager.synchronizeMembers just to see if this would aid in the data being displayed in the form. Unfortunately, this does not work.

      I also tried calling markForRedraw on the DynamicForm, but this too did not cause a change in behavior.

      Is there something special I need to do, to cause the form to format the new values and display them? Without the formatter/parser the data just appeared when set on the ValuesManager.
      Last edited by jpappalardo; 24 Sep 2014, 09:34.

      Comment


        #4
        It sounds like you're saying that 'valuesManager.setValue(<fieldName>, <new value>);' simply isn't working for you when you have a editor parser / formatter on the item.
        This should definitely not be the case (and is pretty fundamental functionality so unlikely to be broken in itself).

        You may be passing a value to the item that the formatter doesn't understand (For example, if your formatter always casts the data value from Object to Integer, but the value passed in via setValue is a String, things would break).
        In this case you'd probably see some kind of error or warning (a class cast exception, most likely) in the console that might help clarify what's going on.

        If that's not the problem, probably best to try to simplify down to a little test case we can actually run to see the problem.

        Comment


          #5
          Thank you, this sorted it out for me
          Last edited by jpappalardo; 24 Sep 2014, 09:34.

          Comment

          Working...
          X