| 1 |
// DATA_TEMPLATE: empty_table |
| 2 |
oTest.fnStart( "aoColumns.bUseRendered" ); |
| 3 |
|
| 4 |
/* bUseRendered is used to alter sorting data, if false then the original data is used for |
| 5 |
* sorting rather than the rendered data |
| 6 |
*/ |
| 7 |
|
| 8 |
$(document).ready( function () { |
| 9 |
/* Check the default */ |
| 10 |
var mTmp = 0; |
| 11 |
|
| 12 |
var oTable = $('#example').dataTable( { |
| 13 |
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt", |
| 14 |
"bDeferRender": true, |
| 15 |
"aoColumns": [ |
| 16 |
null, |
| 17 |
{ "fnRender": function (a) { |
| 18 |
if ( a.iDataRow == 0 ) { |
| 19 |
mTmp++; |
| 20 |
return "aaa"; |
| 21 |
} else |
| 22 |
return a.aData[a.iDataColumn]; |
| 23 |
} }, |
| 24 |
null, |
| 25 |
null, |
| 26 |
null |
| 27 |
] |
| 28 |
} ); |
| 29 |
var oSettings = oTable.fnSettings(); |
| 30 |
|
| 31 |
oTest.fnWaitTest( |
| 32 |
"Default for bUseRendered is true - rendered data is used for sorting", |
| 33 |
function () { $('#example thead th:eq(1)').click(); }, |
| 34 |
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == 'aaa'; } |
| 35 |
); |
| 36 |
|
| 37 |
oTest.fnWaitTest( |
| 38 |
"When bUseRendered is false, original data is used for sorting", |
| 39 |
function () { |
| 40 |
mTmp = 0; |
| 41 |
oSession.fnRestore(); |
| 42 |
oTable = $('#example').dataTable( { |
| 43 |
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt", |
| 44 |
"bDeferRender": true, |
| 45 |
"aoColumns": [ |
| 46 |
null, |
| 47 |
{ |
| 48 |
"bUseRendered": false, |
| 49 |
"fnRender": function (a) { |
| 50 |
if ( a.iDataRow == 0 ) { |
| 51 |
mTmp++; |
| 52 |
return "aaa"; |
| 53 |
} else { |
| 54 |
return a.aData[a.iDataColumn]; |
| 55 |
} |
| 56 |
} |
| 57 |
}, |
| 58 |
null, |
| 59 |
null, |
| 60 |
null |
| 61 |
] |
| 62 |
} ); |
| 63 |
$('#example thead th:eq(1)').click(); |
| 64 |
}, |
| 65 |
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == 'All others'; } |
| 66 |
); |
| 67 |
|
| 68 |
|
| 69 |
oTest.fnWaitTest( |
| 70 |
"bUseRendered set to false on one columns and true (default) on two others", |
| 71 |
function () { |
| 72 |
mTmp = 0; |
| 73 |
var mTmp2 = 0; |
| 74 |
var mTmp3 = 0; |
| 75 |
|
| 76 |
oSession.fnRestore(); |
| 77 |
oTable = $('#example').dataTable( { |
| 78 |
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt", |
| 79 |
"bDeferRender": true, |
| 80 |
"aoColumns": [ |
| 81 |
{ |
| 82 |
"fnRender": function (a) { |
| 83 |
if ( a.iDataRow == 0 ) { |
| 84 |
mTmp++; |
| 85 |
return "aaa1"; |
| 86 |
} else { |
| 87 |
return a.aData[a.iDataColumn]; |
| 88 |
} |
| 89 |
} |
| 90 |
}, |
| 91 |
{ |
| 92 |
"bUseRendered": false, |
| 93 |
"fnRender": function (a) { |
| 94 |
if ( a.iDataRow == 0 ) { |
| 95 |
mTmp2++; |
| 96 |
return "aaa2"; |
| 97 |
} else { |
| 98 |
return a.aData[a.iDataColumn]; |
| 99 |
} |
| 100 |
} |
| 101 |
}, |
| 102 |
{ |
| 103 |
"fnRender": function (a) { |
| 104 |
if ( a.iDataRow == 0 ) { |
| 105 |
mTmp3++; |
| 106 |
return "zzz3"; |
| 107 |
} else { |
| 108 |
return a.aData[a.iDataColumn]; |
| 109 |
} |
| 110 |
} |
| 111 |
}, |
| 112 |
null, |
| 113 |
null |
| 114 |
] |
| 115 |
} ); |
| 116 |
}, |
| 117 |
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == 'aaa1'; } |
| 118 |
); |
| 119 |
|
| 120 |
oTest.fnWaitTest( |
| 121 |
"Multi-column rendering - 2nd column sorting", |
| 122 |
function () { $('#example thead th:eq(1)').click(); }, |
| 123 |
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == 'All others'; } |
| 124 |
); |
| 125 |
|
| 126 |
oTest.fnWaitTest( |
| 127 |
"Multi-column rendering - 3rd column sorting", |
| 128 |
function () { |
| 129 |
$('#example thead th:eq(2)').click(); |
| 130 |
$('#example thead th:eq(2)').click(); |
| 131 |
}, |
| 132 |
function () { return $('#example tbody tr:eq(0) td:eq(2)').html() == 'zzz3'; } |
| 133 |
); |
| 134 |
|
| 135 |
oTest.fnWaitTest( |
| 136 |
"Multi-column rendering - 4th column sorting", |
| 137 |
function () { $('#example thead th:eq(3)').click(); }, |
| 138 |
function () { return $('#example tbody tr:eq(0) td:eq(3)').html() == '-'; } |
| 139 |
); |
| 140 |
|
| 141 |
oTest.fnWaitTest( |
| 142 |
"Multi-column rendering - 5th column sorting", |
| 143 |
function () { $('#example thead th:eq(4)').click(); }, |
| 144 |
function () { return $('#example tbody tr:eq(0) td:eq(4)').html() == 'A'; } |
| 145 |
); |
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
oTest.fnComplete(); |
| 151 |
} ); |