<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Adding a date field to a dgrid in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/adding-a-date-field-to-a-dgrid/m-p/486209#M45245</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm using the following sample: &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://developers.arcgis.com/en/javascript/jssamples/fl_dgrid.html" rel="nofollow" target="_blank"&gt;https://developers.arcgis.com/en/javascript/jssamples/fl_dgrid.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;One of my fields is a date field, and I'm having trouble getting it to show up properly (they're showing up as a string of numbers).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've been going through the documentation but haven't had much luck figuring out how to tell dojo to read it as a date and not a string.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 07 Nov 2013 18:39:13 GMT</pubDate>
    <dc:creator>BrettGreenfield__DNR_</dc:creator>
    <dc:date>2013-11-07T18:39:13Z</dc:date>
    <item>
      <title>Adding a date field to a dgrid</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/adding-a-date-field-to-a-dgrid/m-p/486209#M45245</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm using the following sample: &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://developers.arcgis.com/en/javascript/jssamples/fl_dgrid.html" rel="nofollow" target="_blank"&gt;https://developers.arcgis.com/en/javascript/jssamples/fl_dgrid.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;One of my fields is a date field, and I'm having trouble getting it to show up properly (they're showing up as a string of numbers).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've been going through the documentation but haven't had much luck figuring out how to tell dojo to read it as a date and not a string.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Nov 2013 18:39:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/adding-a-date-field-to-a-dgrid/m-p/486209#M45245</guid>
      <dc:creator>BrettGreenfield__DNR_</dc:creator>
      <dc:date>2013-11-07T18:39:13Z</dc:date>
    </item>
    <item>
      <title>Re: Adding a date field to a dgrid</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/adding-a-date-field-to-a-dgrid/m-p/486210#M45246</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;In order to display it as a date string (instead of the Epoch numbers you are currently seeing), you will need to add a formatter function to your data grid for your date field. On the HTML side, add the formatter option on the appropriate line of the table headers like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[HTML] &amp;lt;table dojotype="dojox.grid.DataGrid" jsid="grid" id="grid" selectionMode="none"&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &amp;lt;thead&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &amp;lt;tr&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &amp;lt;th field="OBJECTID" width="0%"&amp;gt;OBJECTID&amp;lt;/th&amp;gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &amp;lt;th field="rdName" width="100%"&amp;gt;rdName&amp;lt;/th&amp;gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &amp;lt;th field="dateCl" formatter="formatGridDate" width="0%"&amp;gt;dateCL&amp;lt;/th&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &amp;lt;th field="dateOp" width="0%"&amp;gt;dateOp&amp;lt;/th&amp;gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &amp;lt;/tr&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &amp;lt;/thead&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &amp;lt;/table&amp;gt;[/HTML]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Next, in JS, you create your formatting function something like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;function formatGridDate(theDate, rowIndex) { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var rowdata = this.grid.getItem(rowIndex); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var theDate = new Date(parseInt(rowdata.&amp;lt;your date filed name here&amp;gt;));&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; theDateString =&amp;nbsp; dojo.date.locale.format(theDate, { &amp;nbsp;&amp;nbsp; selector: 'date', &amp;nbsp;&amp;nbsp; datePattern: 'MM/dd/yyyy'&amp;nbsp;&amp;nbsp; });&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return theDateString; }&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You can refer to the Dojo documentation about this &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://dojotoolkit.org/documentation/tutorials/1.6/populating_datagrid/" rel="nofollow" target="_blank"&gt;here&lt;/A&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Good luck!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Steve&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Nov 2013 20:35:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/adding-a-date-field-to-a-dgrid/m-p/486210#M45246</guid>
      <dc:creator>SteveCole</dc:creator>
      <dc:date>2013-11-07T20:35:24Z</dc:date>
    </item>
  </channel>
</rss>

