| 1 |
// DATA_TEMPLATE: empty_table |
| 2 |
oTest.fnStart( "fnDrawCallback" ); |
| 3 |
|
| 4 |
/* Fairly boring function compared to the others! */ |
| 5 |
|
| 6 |
$(document).ready( function () { |
| 7 |
/* Check the default */ |
| 8 |
var oTable = $('#example').dataTable( { |
| 9 |
"bServerSide": true, |
| 10 |
"sAjaxSource": "../../../examples/server_side/scripts/server_processing.php" |
| 11 |
} ); |
| 12 |
var oSettings = oTable.fnSettings(); |
| 13 |
var mPass; |
| 14 |
|
| 15 |
oTest.fnWaitTest( |
| 16 |
"Default should be null", |
| 17 |
null, |
| 18 |
function () { return oSettings.fnDrawCallback == null; } |
| 19 |
); |
| 20 |
|
| 21 |
|
| 22 |
oTest.fnWaitTest( |
| 23 |
"One argument passed", |
| 24 |
function () { |
| 25 |
oSession.fnRestore(); |
| 26 |
|
| 27 |
mPass = -1; |
| 28 |
$('#example').dataTable( { |
| 29 |
"bServerSide": true, |
| 30 |
"sAjaxSource": "../../../examples/server_side/scripts/server_processing.php", |
| 31 |
"fnDrawCallback": function ( ) { |
| 32 |
mPass = arguments.length; |
| 33 |
} |
| 34 |
} ); |
| 35 |
}, |
| 36 |
function () { return mPass == 1; } |
| 37 |
); |
| 38 |
|
| 39 |
|
| 40 |
oTest.fnWaitTest( |
| 41 |
"That one argument is the settings object", |
| 42 |
function () { |
| 43 |
oSession.fnRestore(); |
| 44 |
|
| 45 |
oTable = $('#example').dataTable( { |
| 46 |
"bServerSide": true, |
| 47 |
"sAjaxSource": "../../../examples/server_side/scripts/server_processing.php", |
| 48 |
"fnDrawCallback": function ( oSettings ) { |
| 49 |
mPass = oSettings; |
| 50 |
} |
| 51 |
} ); |
| 52 |
}, |
| 53 |
function () { return oTable.fnSettings() == mPass; } |
| 54 |
); |
| 55 |
|
| 56 |
|
| 57 |
oTest.fnWaitTest( |
| 58 |
"fnRowCallback called once on first draw", |
| 59 |
function () { |
| 60 |
oSession.fnRestore(); |
| 61 |
|
| 62 |
mPass = 0; |
| 63 |
$('#example').dataTable( { |
| 64 |
"bServerSide": true, |
| 65 |
"sAjaxSource": "../../../examples/server_side/scripts/server_processing.php", |
| 66 |
"fnDrawCallback": function ( ) { |
| 67 |
mPass++; |
| 68 |
} |
| 69 |
} ); |
| 70 |
}, |
| 71 |
function () { return mPass == 1; } |
| 72 |
); |
| 73 |
|
| 74 |
oTest.fnWaitTest( |
| 75 |
"fnRowCallback called once on each draw there after as well", |
| 76 |
function () { |
| 77 |
$('#example_next').click(); |
| 78 |
$('#example_next').click(); |
| 79 |
$('#example_next').click(); |
| 80 |
}, |
| 81 |
function () { return mPass > 1; } |
| 82 |
); |
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
oTest.fnComplete(); |
| 89 |
} ); |