Sorting one column based on other column (byte size vs. human readable size)

Sorting one column based on other column (byte size vs. human readable size)

haroldharold Posts: 2Questions: 0Answers: 0
edited December 2010 in General
Hello,
I would like to sort the output of one column based on another (hidden) column.
I have a column (Size) that contains human readable file sizes (2.3 MB, 1.2 GB, etc.)
When a user sorts this column 2.3MB appears above 1.2GB (based on numerical sorting)
This behavior is not what I want, obviously, instead I would like to sort based on another column that simply contains the number of bytes.
Is there any way to do this?

Thanks :)

Replies

  • allanallan Posts: 63,512Questions: 1Answers: 10,472 Site admin
    There sure is: http://datatables.net/plug-ins/sorting#file_size :-)

    Allan
  • haroldharold Posts: 2Questions: 0Answers: 0
    Thanks Allan, can't believe it was that obvious :)
    However, I'm having trouble getting it to actually work.
    I've pasted the plugin code and set sType in aoColumns, but now it's not sorting the column at all. Not Sure what I could be doing wrong :-/
    Perhaps the plugin doesn't support KB as a size?
This discussion has been closed.