fmt:formatDate JSTL tag and custom date sort issue

fmt:formatDate JSTL tag and custom date sort issue

jgouletjgoulet Posts: 26Questions: 2Answers: 1
edited August 2013 in General
Ok, so I have been scouring the internet for a few days now, and I'm still stumped. I have a JSP that makes a database call, and displays the data in a Datatables table. Now, when the date is passed to the page, it is in the format of yyyy-MM-dd hh:mm:ss. Our users (U.S.) are accustomed to seeing the MM/dd/yyyy format, so I use a fmt:formatDate JSTL tag to display it as such. Unfortunately, for whatever reason, the JS does not like that tag, and I'm not sure why.

Here is the javascript:

[code]jQuery.extend( jQuery.fn.dataTableExt.oSort, {
"date-us-pre": function ( a ) {
var usDatea = a.split('/');
return (usDatea[2] + usDatea[1] + usDatea[0]) * 1;
},

"date-us-asc": function ( a, b ) {
return ((a < b) ? -1 : ((a > b) ? 1 : 0));
},

"date-us-desc": function ( a, b ) {
return ((a < b) ? 1 : ((a > b) ? -1 : 0));
}
} );[/code]
I have that in a file called jquery.datesort.js which I include on the page. The following is the initialization that I use:

[code]$(document).ready(function() {
$('#institution').dataTable( {
"sScrollY": "200px",
"iDisplayLength": 25,
"sPaginationType": "full_numbers",
"bScrollCollapse": true,
"aoColumns": [
null,
null,
null,
null,
null,
{ "sType": "date-us" },
null,
null
]
} )
} );[/code]
I know that this works, because I tested it against dummy data, where I simply hard-coded the dates in the format of MM/dd/yyyy into the table. The sort worked as expected when I did that (sorting by year, then month, then day).

Now here is the code for the table body:

[code]













[/code]
This works fine to output the data into the format of MM/dd/yyyy, but for some reason, my sort simply does not like it. When I click on the sort buttons, they change image (up arrow to down arrow, and vice versa) to reflect that a sort is being performed, but the data is not sorting on the screen. Also, if I remove the fmt:formatDate tag and comment out the js for the date sort, the date will render as yyyy-MM-dd hh:mm:ss, and will sort that way without issue (as expected).

I am a bit puzzled, because it was my belief that the fmt:formatDate would be taking place on the server side since it is JSTL. That would mean that the client would only see the post-formatted data of MM/dd/yyyy, and when the js does it's thing on the client side, it shouldn't be any different than when I hard-coded the dates... but that is not happening.

Any ideas? Is there some kind of glaring issue that I'm missing?

Replies

  • jgouletjgoulet Posts: 26Questions: 2Answers: 1
    I should also add that I am using JDeveloper 11G R2. This behavior occurs in both the integrated WebLogic server and stand-alone WebLogic server.
  • jgouletjgoulet Posts: 26Questions: 2Answers: 1
    Ok, so when I view source, it looks like the data isn't being passed to the browser, which would explain why the sort won't work. Guess I need to dig around the app a bit more.
  • jgouletjgoulet Posts: 26Questions: 2Answers: 1
    Actually, I was mistaken. The data is getting to the browser, I was just seeing some null values, which shouldn't matter. Still stumped on this.
  • jgouletjgoulet Posts: 26Questions: 2Answers: 1
    Solved: there were tags that were also being used. After removing them, everything works as it should.
This discussion has been closed.