Announcement

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

    SQL datetime --> FieldType Date, loosing hour:minute

    Hello,
    SmartGWT version: 2.4

    Using a SQL datasource, I'm retrieving a SQL datetime from db in a datasource with a fieldType Date.

    The value in db: 2009-06-16 11:21:21.92
    The javascript value: addedDate:new Date(1245124800000)
    The listgrid displayed value: 2009-06-16 00:00

    Why is it loosing the hour:minute values ?

    thanks

    #2
    A field type of date drops the time. If you want both, use type of datetime.

    Comment


      #3
      Thanks for your response.

      The Javadoc mentions about the DATE FieldType:
      public static final FieldType DATE
      A date, including time of day. Represented on the client as a JavaScript Date object. object.

      So according to this, the time of day is not dropped. But the main reason why I switched from datetime to date is explained below.

      Problem with datetime fieldtype is that client side sorting in a listgrid doesn't handle null values properly. On the other hand the date fieldtype is handled correctly, meaning when you sort on the listgrid by ascending or descending order, the null values are either all at the bottom or all at the top.

      Which is not what is happening with datetime, the null values are not properly sorted.

      See the attachment for an example of what is wrong with datetime.

      Part of the SQL datasource below:
      Code:
       <fields>
            <field name="clientNum" type="text" required="true" hidden="true" />
            <field name="noEq" type="text" />
            <field name="addedDate" type="datetime" />
            <field name="addedBy" type="text" />
            <field name="disabledDate" type="datetime" />
            <field name="modifiedBy" type="text" />
            <field name="service" type="text" />
            <field name="comment" type="text" />
         </fields>

      Anyone knows why datetime sorting in a ListGrid doesn't function as it should ?
      Attached Files

      Comment


        #4
        Those field type definitions are confusing. I'm not sure why the sort order is not correct. Maybe if you pull the data response from the developer console and post that it will be more clear.

        Comment


          #5
          Concerning the sort problem


          Here's the response snippet for a record with a non null datetime fieldtype (look at disabledDate):
          Code:
                      {
                          addedDate:new Date(1195588077097), 
                          serialNo:"00730443603773", 
                          noEq:925477,              
                          disabledDate:new Date(1196182982000), 
                          service:"NCA", 
                      },
          Here's the response snippet for a record with a null datetime fieldtype. You will notice that, since the disabledDate from the DB is null the field is omitted in the response. Hence resulting in an empty (null) value in the ListGrid. So far so good, again I suspect the sorting problems comes from a combination of: ListGrid + datasource datetime fieldType + a null value

          Code:
                      {                
                          noEq:928377, 
                          serialNo:"00730443603773", 
                          addedDate:new Date(1196448515930), 
                          service:"NCA", 
                      },

          Comment


            #6
            The docs for the "DATE" fieldType are indeed corrupted, here's the right doc, which will be restored in nightly builds shortly:

            A logical date, with no time value (such as a holiday or birthday).
            Represented on the client as a JavaScript Date object with
            all time fields set to zero in browser local time. Transmitted in
            UTC/GMT by default. See Date Format and Storage for more
            information on date display and serialization formats.
            Are you having a problem with client-side or server-side sort? You can tell a client-side sort by the fact that there's no server request (and to force this situation you can reduce the dataset before requesting the sort - see the Adaptive Sort example).

            If it's really a server-side sort problem, please indicate what the SQL engine is, show the actual table information and the full SQL DataSource (including all operationBindings, if any).

            Comment

            Working...
            X