Sorting FileSizes

Sorting FileSizes

JPBCDEJPBCDE Posts: 11Questions: 0Answers: 0
edited November 2011 in DataTables 1.8
I need help please. Im trying to sort a column that contains file sized in KB, MB, GB. I've searched this site and the plugins and tried putting something together, but it still seems to sort as text. Any help would be appreciated.

Test site : http://live.datatables.net/utirij/edit#javascript,html,live

I started with this thread : http://www.datatables.net/forums/discussion/2517/solved-sorting-a-table-column/p1

Thank you

Replies

  • fobosfobos Posts: 14Questions: 0Answers: 0
    edited November 2011
    The correct code

    $(document).ready(function() {
    $('#trafficreport').dataTable({
    "bJQueryUI": true,
    "sDom": '<"H"Tfr>t<"F"ip>',
    "oTableTools": {
    "sSwfPath": "/js/swf/copy_cvs_xls_pdf.swf",
    "aButtons": [
    "copy",
    "csv",
    {
    "sExtends": "print",
    "sMessage": "Traffic ReportStart Date: 2011/11/01
    End Date: 2011/11/30
    ",
    "bShowAll": true
    }
    ]
    },
    "sPaginationType": "full_numbers",
    "bLengthChange": true,
    "iDisplayLength": 10000,
    "bSort": true,
    "bDestroy": true,
    "bAutoWidth": false,
    "aoColumns" : [
    { sWidth : "5%" },
    { sWidth : "40%" },
    { sWidth : "40%"},
    { sWidth : "15%", "sType": "file-size" }
    ]
    });
    });
  • JPBCDEJPBCDE Posts: 11Questions: 0Answers: 0
    Sorry, but I see no difference if i use your code in the jsbin?!
  • fobosfobos Posts: 14Questions: 0Answers: 0
    edited November 2011
    See :

    http://live.datatables.net/utirij/3/edit

    The error was here :
    { sWidth : "5%" },
    { sWidth : "40%" },
    { sWidth : "40%", "sType": "file-size" },
    { sWidth : "15%"}

    is this the correct code :

    { sWidth : "5%" },
    { sWidth : "40%" },
    { sWidth : "40%"},
    { sWidth : "15%", "sType": "file-size" }
  • JPBCDEJPBCDE Posts: 11Questions: 0Answers: 0
    Hi fobos,

    Sorry i missed what you did. I see now, thank you so much :)
This discussion has been closed.