Announcement

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

    DateTimeItem displaying Date.toString instead of formatter

    I fetch data to fill a value for a DateTimeItem that has a formatter. However, the value in the text part of the item is not formatted and appears as a Date.toString() string:
    Code:
    Wed Sep 28 09:58:06 PDT 2011
    I know it's returning a Date object because when I check the dev console it has:
    Code:
    time:new Date(1317229086303),
    When I use the date picker to choose a date, the date appears as it should:
    Code:
    2011/09/28 00:00
    Here is my code:
    Code:
    DateTimeItem item = new DateTimeItem("time");
    item.setDateFormatter(DateDisplayFormat.TOJAPANSHORTDATETIME);
    item.setValueFormatter(new DateTimeFormItemValueFormatter());
    Any ideas on how to make the fetched value display in the format I want?

    Using SmartGWT 2.4 Power with IE7

    #2
    For display, the DataSourceField declaration is what matters - ensure it has type="datetime" and that you haven't provided a ListGridField definition with a conflicting type.

    Comment


      #3
      Thanks for the reply. I'm at lost because the DataSourceField is of type datetime and the item definition I'm passing to the DynamicForm is a DateTimeItem item.

      Comment


        #4
        Well, the problem is not with the approach you've described or the code you've shown so far :). So let us know if you can share more details that would allow us to help further.

        Comment


          #5
          I noticed that on another DateTimeItem that the formatter was working correctly. The difference was that one was getting a default value from a call to setDefaultValue instead of a fetchData. So I thought what if I tried setting the value manually after the fetch in the callback and it worked!

          Comment

          Working...
          X