Select to view content in your preferred language

Dojo Datagrid doesn't return SDE date format field correctly for related table

1775
6
10-06-2010 12:42 PM
MatthewGubitosa
New Contributor III
ArcGIS Server 10, ArcMap 10, ArcSDE 9.3.1 on SQLServer 2005

I've used the "Query related records (multiple)" example on the Javascript API Samples page:
http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples_start.htm#jssamples/fl_query_relat...
and successfully translated it to return data from a local map service serving a feature class and a 1:M related table from SDE.  It works fine except for one thing, sde Date field in the related table is returned as a mysterious 13-digit number - see attached screenshot.

Seems like DOJO Datagrid doesn't quite deal with the date field properly. Has anyone solved this problem?
0 Kudos
6 Replies
KellyHutchins
Esri Frequent Contributor
You can apply a formatter to the date field that will convert the current format to a more readable date format. To use a formatter create a function that will return the date, in this example dojo.date.locale.format is used to return the date in a format like August 14, 2007.

      function formatDate(value){
        var inputDate = new Date(value);
        return dojo.date.locale.format(inputDate, {
          selector: 'date',
          datePattern: 'MMMM d, y' 
        });
      }



Apply the formatter to the date field:

<th field="DATEFIELD" formatter="formatDate;">Date</th>


Take a look at the following sample in the help to see an example:
http://help.arcgis.com/EN/webapi/javascript/arcgis/demos/fl/fl_paging.html
by Anonymous User
Not applicable
I am getting this same error using Flex. I tried using a date formatter but it doesn't seem to wanna work either. you guys have any luck?
0 Kudos
AlexSanders
Occasional Contributor
I'm getting the issue in the Flex Viewer Application.  The link below for help is not working.  Does anybody know of any help on this issue?
0 Kudos
DavidJenkins
New Contributor III
The function that Kelly posted is correct however the code for the HTML has an error.  Remove the semicolon after formatDate and this will work fine.

The HTML line for the date field should look like this:

<th field="DATEFIELD" formatter="formatDate">Date</th>
GwynnHarlowe
New Contributor II

Thank you, been looking for the answer to this!!!

0 Kudos