[6286] | 1 | // DATA_TEMPLATE: dom_data |
---|
| 2 | oTest.fnStart( "aoColumns.iDataSort" ); |
---|
| 3 | |
---|
| 4 | $(document).ready( function () { |
---|
| 5 | /* Should know that sorting already works by default from other tests, so we can jump |
---|
| 6 | * right in here |
---|
| 7 | */ |
---|
| 8 | var oTable = $('#example').dataTable( { |
---|
| 9 | "aoColumns": [ |
---|
| 10 | null, |
---|
| 11 | { "iDataSort": 4 }, |
---|
| 12 | null, |
---|
| 13 | null, |
---|
| 14 | null |
---|
| 15 | ] |
---|
| 16 | } ); |
---|
| 17 | var oSettings = oTable.fnSettings(); |
---|
| 18 | |
---|
| 19 | oTest.fnTest( |
---|
| 20 | "Sorting on first column is uneffected", |
---|
| 21 | null, |
---|
| 22 | function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == 'Gecko'; } |
---|
| 23 | ); |
---|
| 24 | |
---|
| 25 | oTest.fnTest( |
---|
| 26 | "Sorting on second column is the order of the fifth", |
---|
| 27 | function () { $('#example thead th:eq(1)').click(); }, |
---|
| 28 | function () { return $('#example tbody tr:eq(0) td:eq(4)').html() == 'A'; } |
---|
| 29 | ); |
---|
| 30 | |
---|
| 31 | oTest.fnTest( |
---|
| 32 | "Reserve sorting on second column uses fifth column as well", |
---|
| 33 | function () { $('#example thead th:eq(1)').click(); }, |
---|
| 34 | function () { return $('#example tbody tr:eq(0) td:eq(4)').html() == 'X'; } |
---|
| 35 | ); |
---|
| 36 | |
---|
| 37 | oTest.fnTest( |
---|
| 38 | "Sorting on 5th column retains it's own sorting", |
---|
| 39 | function () { $('#example thead th:eq(4)').click(); }, |
---|
| 40 | function () { return $('#example tbody tr:eq(0) td:eq(4)').html() == 'A'; } |
---|
| 41 | ); |
---|
| 42 | |
---|
| 43 | |
---|
| 44 | oTest.fnTest( |
---|
| 45 | "Use 2nd col for sorting 5th col and via-versa - no effect on first col sorting", |
---|
| 46 | function () { |
---|
| 47 | mTmp = 0; |
---|
| 48 | oSession.fnRestore(); |
---|
| 49 | oTable = $('#example').dataTable( { |
---|
| 50 | "aoColumns": [ |
---|
| 51 | null, |
---|
| 52 | { "iDataSort": 4 }, |
---|
| 53 | null, |
---|
| 54 | null, |
---|
| 55 | { "iDataSort": 1 } |
---|
| 56 | ] |
---|
| 57 | } ); |
---|
| 58 | }, |
---|
| 59 | function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == 'Gecko'; } |
---|
| 60 | ); |
---|
| 61 | |
---|
| 62 | oTest.fnTest( |
---|
| 63 | "2nd col sorting uses fifth col", |
---|
| 64 | function () { $('#example thead th:eq(1)').click(); }, |
---|
| 65 | function () { return $('#example tbody tr:eq(0) td:eq(4)').html() == 'A'; } |
---|
| 66 | ); |
---|
| 67 | |
---|
| 68 | oTest.fnTest( |
---|
| 69 | "2nd col sorting uses fifth col - reversed", |
---|
| 70 | function () { $('#example thead th:eq(1)').click(); }, |
---|
| 71 | function () { return $('#example tbody tr:eq(0) td:eq(4)').html() == 'X'; } |
---|
| 72 | ); |
---|
| 73 | |
---|
| 74 | oTest.fnTest( |
---|
| 75 | "5th col sorting uses 2nd col", |
---|
| 76 | function () { $('#example thead th:eq(4)').click(); }, |
---|
| 77 | function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == 'All others'; } |
---|
| 78 | ); |
---|
| 79 | |
---|
| 80 | oTest.fnTest( |
---|
| 81 | "5th col sorting uses 2nd col - reversed", |
---|
| 82 | function () { $('#example thead th:eq(4)').click(); }, |
---|
| 83 | function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == 'Seamonkey 1.1'; } |
---|
| 84 | ); |
---|
| 85 | |
---|
| 86 | |
---|
| 87 | oTest.fnComplete(); |
---|
| 88 | } ); |
---|