Not needing up and down image for sorting
Not needing up and down image for sorting
Does anybody know if it's possible to use DataTables and just have the user click on the column name to sort? Right now, I've loaded the up and down images on the server, but they are not showing anyway. But you can get it to sort by moving the mouse off the title. Here is an example:
http://www.insightla.org/audio/index3.asp
Anyway, it's confusing to the user at this point.
Any help you can provide would be much appreciated.
Thanks,
Allen
http://www.insightla.org/audio/index3.asp
Anyway, it's confusing to the user at this point.
Any help you can provide would be much appreciated.
Thanks,
Allen
This discussion has been closed.
Replies
Allan
http://www.insightla.org/admin/test.asp
Is there something I'm missing?
Allen
I took a quick look at your page, and noticed that you are getting several javascript errors (jQuery not being defined).
Further investigation turns out that you are including jquery.dataTables.js before jquery.js. This is a problem because datatables is a plugin for jQuery, and as such needs jQuery to be included first.
Change this:
[code]
[/code]
to this:
[code]
[/code]
And hopefully this will fix the problems.
Cheers,
-Chris
---
Unmatched encountered. Ignoring tag.
test.asp:196Unmatched encountered. Ignoring tag.
jquery.dataTables.js:5726DataTables warning (table id = 'table_arch'): Unexpected number of TD elements. Expected 76 and got 73. DataTables does not support rowspan / colspan in the table body, and there must be one cell for each row/column combination.
---
Every row needs a td tag for each column, and the first row only has one td tag. (But there are 4 columns)
Most likely missing a closing tag somewhere...
Hope this helps
I haven't done this before, but from what I understand, all you need to do is include the javascript provided on that page after you include jquery.dataTables.js, but before you initialize the dataTable ($().dataTable();).
When initializing the dataTable, you need to set the date column to use the sorting type you included - in this case, uk_date.
Just add the aoColumnsDef part from below, and (with the other javascript code above it), sorting should work.
[code]
jQuery.fn.dataTableExt.oSort['uk_date-asc'] = function(a,b) {
var ukDatea = a.split('/');
var ukDateb = b.split('/');
var x = (ukDatea[2] + ukDatea[1] + ukDatea[0]) * 1;
var y = (ukDateb[2] + ukDateb[1] + ukDateb[0]) * 1;
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
};
jQuery.fn.dataTableExt.oSort['uk_date-desc'] = function(a,b) {
var ukDatea = a.split('/');
var ukDateb = b.split('/');
var x = (ukDatea[2] + ukDatea[1] + ukDatea[0]) * 1;
var y = (ukDateb[2] + ukDateb[1] + ukDateb[0]) * 1;
return ((x < y) ? 1 : ((x > y) ? -1 : 0));
};
$(document).ready(function() {
$('#table_audio').dataTable({
"bPaginate": false,
"bInfo": false,
"bFilter": false,
"aoColumnDefs": [{"sType" : 'uk_date', "aTargets" : [1]}]
});
} );
[/code]
Hope this helps.