[How to] use (hidden sorting) plug-in
[How to] use (hidden sorting) plug-in
Hi there
I'd like to start by saying a big thanks for this script, which helped us a lot in our devs.
It's easy to implemente, and quite effective.
But I now try to use the plug-ins, and I wouldn't say the same :)
I looked the forum, tried some of the tips, but can't make the plug-in "Hidden title numeric sorting" to work
here is my code :
[code]
jQuery.fn.dataTableExt.oSort['title-numeric-asc'] = function(a,b) {
var x = a.match(/title="*(-?[0-9]+)/)[1];
var y = b.match(/title="*(-?[0-9]+)/)[1];
x = parseFloat( x );
y = parseFloat( y );
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
};
jQuery.fn.dataTableExt.oSort['title-numeric-desc'] = function(a,b) {
var x = a.match(/title="*(-?[0-9]+)/)[1];
var y = b.match(/title="*(-?[0-9]+)/)[1];
x = parseFloat( x );
y = parseFloat( y );
return ((x < y) ? 1 : ((x > y) ? -1 : 0));
};
$(document).ready(
function()
{
$('.display').dataTable( {
"bPaginate": false,
"bFilter": true,
"bInfo": false,
"aoColumns": [
null,
null,
null,
null,
null,
null,
{"sType": "numeric"},
null,
null,
null,
null,
null,
null
]} );
}
);
[/code]
And one of the TDs that I want to order, as an example
443.96 Mo
problem : when I clic on the TH for "File size", nothing happens.
But the other columns work fine
Firefox 4 / WinXP
Anyone can see what I have done wrong?
I find implementing the Datatables plug-ins quite confusing, and we have very few live examples on the site.
I'd like to start by saying a big thanks for this script, which helped us a lot in our devs.
It's easy to implemente, and quite effective.
But I now try to use the plug-ins, and I wouldn't say the same :)
I looked the forum, tried some of the tips, but can't make the plug-in "Hidden title numeric sorting" to work
here is my code :
[code]
jQuery.fn.dataTableExt.oSort['title-numeric-asc'] = function(a,b) {
var x = a.match(/title="*(-?[0-9]+)/)[1];
var y = b.match(/title="*(-?[0-9]+)/)[1];
x = parseFloat( x );
y = parseFloat( y );
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
};
jQuery.fn.dataTableExt.oSort['title-numeric-desc'] = function(a,b) {
var x = a.match(/title="*(-?[0-9]+)/)[1];
var y = b.match(/title="*(-?[0-9]+)/)[1];
x = parseFloat( x );
y = parseFloat( y );
return ((x < y) ? 1 : ((x > y) ? -1 : 0));
};
$(document).ready(
function()
{
$('.display').dataTable( {
"bPaginate": false,
"bFilter": true,
"bInfo": false,
"aoColumns": [
null,
null,
null,
null,
null,
null,
{"sType": "numeric"},
null,
null,
null,
null,
null,
null
]} );
}
);
[/code]
And one of the TDs that I want to order, as an example
443.96 Mo
problem : when I clic on the TH for "File size", nothing happens.
But the other columns work fine
Firefox 4 / WinXP
Anyone can see what I have done wrong?
I find implementing the Datatables plug-ins quite confusing, and we have very few live examples on the site.
This discussion has been closed.
Replies
Allan
Thanks again, and WOW for the support, that the kind of script I was happy to make a donation to and i don't regret it one bit :)
And an idea : you could place the link to the online example directly below the description of each plug-in, or next to "Show detail"