dd-mon-yyyy IE shim
dd-mon-yyyy IE shim
The organization I support dictates that all dates will be shown in dd-MON-yyyy format (10-SEP-2006, 08-MAY-2013).
When run on Chrome, dataTables correctly recognizes this pattern as a date.
Unfortunately, we also have to support IE7. Thankfully I came across abbottmw's sorting function for my pattern (http://datatables.net/forums/discussion/1933/dd-mon-yyyy-date-format/p1#Comment_8401).
My question is, what is the syntax for using abbottmw's sorting function for only IE, but not for Chrome? Is there a way I can do the sorting declaration conditionally?
Please see http://jsfiddle.net/jhfrench/zpWWa/ for an example dataset.
When run on Chrome, dataTables correctly recognizes this pattern as a date.
Unfortunately, we also have to support IE7. Thankfully I came across abbottmw's sorting function for my pattern (http://datatables.net/forums/discussion/1933/dd-mon-yyyy-date-format/p1#Comment_8401).
My question is, what is the syntax for using abbottmw's sorting function for only IE, but not for Chrome? Is there a way I can do the sorting declaration conditionally?
Please see http://jsfiddle.net/jhfrench/zpWWa/ for an example dataset.
This discussion has been closed.
Replies
Allan
> Is there a way to shim IE's JavaScript at a higher level?
As in replace the Date object? You probably could, but I suspect there is a belly full of hurt in that direction...
> Within the plugin code, or within the `dataTable();` call?
I'd suggest doing the detection just before the `dataTable()` call, and then using the result in the initialisation object. You'd set sType to point to the plug-in, or have it use `null` (for Chrome etc).
The other option is to always use a plug-in, optionally with feature detection inside it. Additionally you could possibly use a type detection plug-in to perform this action.
Out of interest, what is the date format that you are using?
Allan
[code]
var canParse = ! isNaN( Date.parse('08-MAY-2013') );
[/code]
Allan
If you're inclined to incorporate it, I can contribute the "dd-MMM-YYYY" sorting algorithm to the Github project (via a pull request). If so, in which folder should it (http://appliedinter.net/Workstream/common_files/js/dataTable_shim_dd-MMM-yyyy.js) be added? DataTables\examples\plug-ins?
If you could issue a pull request, that would be great. It should go into here: https://github.com/DataTables/Plugins/tree/master/sorting
Allan