Stumped on a sorting problem.

Stumped on a sorting problem.

licht100licht100 Posts: 5Questions: 0Answers: 0
edited September 2010 in General
25000+ tables created now using DataTables no problems. Great java script. I finally ran into a strange problem
with sorting. So here it is:

Just a simple initialization. Has worked fine on everything else.

[code]

$(document).ready(function() {
oTable = $('.datatable').dataTable({

"bJQueryUI": true,

});
});

[/code]

The problem I'm having is trying to sort columns with graphic images or rather strange values in them.

So If I have x9 rows that look like this. So 10-19.gif it works perfectly. So with 9 different .gif images it works.
Now heres the strange thing, as soon as I add the #10 .gif image the sorting stops working totally. It just
randomly sorts the images when I click the sort tab. I've tried using all sorts of different values for the .gif
images nothing seems to work. So I'm guessing that its the strange type values.
But I'm baffled why it works perfectly with 9 values. Any help would be much appreciated.

[code]
1


2


3

[/code]

etc etc.

Replies

  • robbiesmith79robbiesmith79 Posts: 16Questions: 0Answers: 0
    Because 1 comes before 9 when counting. Alphanumeric counting to 20: 0,1,10,11,12,13,14,15,16,17,18,19,2,20,3,4,5,6,7,8,9

    You need a different naming convention on the images. You can see this same thing happening when you have a date column and you use human readable friendly dates: 9/27/2010 2:36 PM (is bad) whereas 2010-09-07 02:36:00 works perfectly.

    I agree, there should be some sort of support for this.
  • robbiesmith79robbiesmith79 Posts: 16Questions: 0Answers: 0
    DUH moment. An easy fix. If you can detect the numbers of the file names as they're going in. Preceed any single digit image with 0 or the max number of digits in the convention
    01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20
  • licht100licht100 Posts: 5Questions: 0Answers: 0
    For the sake of argument I tried your naming convention and it behaves the same way. All the .gif files
    are static. It's really simple just 10 different .gif images.

    01, 02, 03, 04, 05, 06, 07, 08, 09 those all sort and work fine. As soon as I add the 10 the whole sort order
    becomes random.

    It's really strange. I guess I need to make a custom sorting script, which I was trying to avoid as it's just 10 files.
  • licht100licht100 Posts: 5Questions: 0Answers: 0
    Probally should have read the documentation a little more before I posted this originally.

    But turning off the auto HTML parsing on the columns worked.

    [code]
    "aoColumnDefs": [
    { "sType": "string", "aTargets": [ 1,2 ] }
    ]
    [/code]

    But my theory on how this works is, datatables looks at as a
    NULL value. By default the HTML parser is turned on and it ignores anything between a
    < > for the purposes of sorting.
This discussion has been closed.