Note that there are some explanatory texts on larger screens.

plurals
  1. PODojo Grid refuses to sort by Date. How to get this to work?
    primarykey
    data
    text
    <p>I have a Dojo Grid with a date column. Despite using a custom formatter, it always does a string sort. Note that my incoming dates will be formatted as 02/17/2005 and I cannot change that.</p> <pre><code>formatDate = function(d){ return dojo.date.locale.format(new Date(d), {datePattern: "M/dd/yyyy", formatLength: 'short', selector: "date"}); } var myData= [ {field: "transactionDate", name: "Transaction Date", width: "115px", datatype: "date", formatter: formatDate }, {field: "description", name: "Transaction Description", width: "170px" }, ]]; var storeData = { items: [ { transactionDate:"04/15/2011", description:"A description of the transaction" } , { transactionDate:"04/15/2011", description:"A description of the transaction" } , { transactionDate:"04/15/2011", description:"A description of the transaction" } , { transactionDate:"04/15/2011", description:"A description of the transaction" } , { transactionDate:"02/15/2010", description:"A description of the transaction" } , { transactionDate:"01/15/2011", description:"A description of the transaction" } , { transactionDate:"04/15/2011", description:"A description of the transaction" } , { transactionDate:"09/15/2009", description:"A description of the transaction" } , { transactionDate:"04/15/2011", description:"A description of the transaction" } , { transactionDate:"04/15/2011", description:"A description of the transaction" } ]}; </code></pre> <hr> <pre><code> &lt;div class="claro" style="width: 835px; height: 300px;"&gt; &lt;div dojotype="dojo.data.ItemFileReadStore" jsID="dataStoreForGrid" data="storeData"&gt;&lt;/div&gt; &lt;div id="grid" dojotype="dojox.grid.DataGrid" store="transferStoreForGrid" clientSort="true" jsID="SomeId" structure="myData" rowsperpage="40" &gt;&lt;/div&gt; &lt;/div&gt; </code></pre> <hr> <p>Per Peller's suggestion, I tried formatting as ISO date. Thais had no affect on sorting:</p> <pre><code> formatDate = function(d){ var d2 = dojo.date.stamp.fromISOString(ISODateString(new Date(d))); return dojo.date.locale.format(d2, {selector: 'date', formatLength: 'long'}); } function ISODateString(d) { function pad(n){ return n&amp;lt;10 ? '0'+n : n } return d.getUTCFullYear()+'-' + pad(d.getUTCMonth()+1)+'-' + pad(d.getUTCDate())+'T' + pad(d.getUTCHours())+':' + pad(d.getUTCMinutes())+':' + pad(d.getUTCSeconds())+'Z' } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload