[Dojo-interest] SortableTable - Sort by date with British date
format - not working
Tom Trenka
dojo-interest at dept-z.com
Thu Aug 10 19:41:40 MDT 2006
Don't know if you work against the head or not but the new FilteringTable
widget is set up to do this, pretty much...
trt
Rick Morrison-3 wrote:
>
> I'm not sure if this is directly applicable to the ST widget in its
> current
> state, but I did want to get this thought down for a possible future
> enhancement to the ST widget or some future grid widget.
>
> If the widget in question kept the data it was to display (lets call that
> its "backing store") separately from the text that was displayed (the
> generated HTML), this would be trivial.
>
> Let's say the widget was to display a list of names and birthdates, and
> this
> hypothetical widget used native JS objects as its backing store, like
> this:
>
> [
> {nm:'Lyndon B. Johnson', bdate:new Date(1908, 7, 27)},
> {nm:'John F. Kennedy', bdate:new Date(1917,4,29)},
> {nm:'Lee Harvey Oswald', bdate:new Date(1939,9,18)}
> ]
>
> If the widget has some "render" mechanism that could be somehow set,
> through
> some combination of standard type introspection and user-provided custom
> functions to use a set of "stringify" functions that would turn those
> dates
> into British date strings:
>
> widget.colrenderers = {
> nm:String,
> bdate:dojo.lang.curry(window, dojo.date.format, null, '%d/%m/%Y'))
> }
>
> Well, then a sort function could then sort the backing store on the
> underlying native JS Date object and get you the right sort order no
> matter
> what string format you were using to display the dates.
>
> Rick
>
>
> On 8/10/06, Tom Trenka <dojo-interest at dept-z.com> wrote:
>>
>>
>> You're pretty good at finding known bugs, aren't you...
>>
>> The Date parsing that happens with the sortable table is the native JS
>> date
>> parsing (i.e. new Date(value)), and apparently it doesn't really like any
>> kind of localization--which means that it thinks your date is mm/dd/yyyy,
>> and obviously it's not. Unfortunately I can't do anything about it (yet)
>> but once localization is done and in, I can address this problem
>> (although
>> I'm open to suggestions).
>>
>> trt
>>
>>
>> Damian Sutton wrote:
>> >
>> > Hi Guys,
>> >
>> > I am working with the SortableTable widget and I am having major
>> problems
>> > with
>> > sorting by date.
>> >
>> > Normally I have no problem, but since I have tried to display the date
>> in
>> > the
>> > British format i.e. dd/mm/yyyy, this is where things start acting
>> strange.
>> >
>> > Firstly I set the column header with dataType="Date" and
>> format="%d/%m/%Y"
>> > (Btitish format). Then by following the examples, I actually place the
>> > date
>> > into my table in the American format i.e. mm/dd/yyyy.
>> >
>> > The problem is, if I feed in a date such as 03/13/2006(mm/dd/yyyy) it
>> > actually
>> > displays 01/03/2007 (in what seems to by in mm/dd/yyyy). It is as if it
>> is
>> > not
>> > taking any notice of the format attibute that I place in the <th>.
>> >
>> > Because that failed I tried placing the data into my table with the
>> > dd/mm/yyyy
>> > format, but again while I feed it 03/13/2006 it again displays
>> 01/03/2007
>> > in
>> > the table.
>> >
>> > I also tried setting the defaultDateFormat of the table to %d/%m/%Y,
>> but
>> > still
>> > have the same problem.
>> >
>> >
>> > I really can't see where I am going wrong, anyone have any ideas.
>> >
>> > Much Thanks,
>> >
>> > Damian
>> >
>> >
>> >
>> > _______________________________________________
>> > Dojo FAQ: http://dojo.jot.com/FAQ
>> > Dojo Book: http://manual.dojotoolkit.org/DojoDotBook
>> > Dojo-interest at dojotoolkit.org
>> > http://dojotoolkit.org/mailman/listinfo/dojo-interest
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/SortableTable---Sort-by-date-with-British-date-format---not-working-tf2085258.html#a5749859
>> Sent from the Dojo forum at Nabble.com.
>>
>> _______________________________________________
>> Dojo FAQ: http://dojo.jot.com/FAQ
>> Dojo Book: http://manual.dojotoolkit.org/DojoDotBook
>> Dojo-interest at dojotoolkit.org
>> http://dojotoolkit.org/mailman/listinfo/dojo-interest
>>
>
> _______________________________________________
> Dojo FAQ: http://dojo.jot.com/FAQ
> Dojo Book: http://manual.dojotoolkit.org/DojoDotBook
> Dojo-interest at dojotoolkit.org
> http://dojotoolkit.org/mailman/listinfo/dojo-interest
>
>
--
View this message in context: http://www.nabble.com/SortableTable---Sort-by-date-with-British-date-format---not-working-tf2085258.html#a5755619
Sent from the Dojo forum at Nabble.com.
More information about the Dojo-interest
mailing list