| 1 |
// DATA_TEMPLATE: empty_table |
| 2 |
oTest.fnStart( "bLengthChange" ); |
| 3 |
|
| 4 |
$(document).ready( function () { |
| 5 |
/* Check the default */ |
| 6 |
$('#example').dataTable( { |
| 7 |
"sAjaxSource": "../../../examples/ajax/sources/objects.txt", |
| 8 |
"aoColumns": [ |
| 9 |
{ "mData": "engine" }, |
| 10 |
{ "mData": "browser" }, |
| 11 |
{ "mData": "platform" }, |
| 12 |
{ "mData": "version" }, |
| 13 |
{ "mData": "grade" } |
| 14 |
] |
| 15 |
} ); |
| 16 |
|
| 17 |
oTest.fnWaitTest( |
| 18 |
"Length div exists by default", |
| 19 |
null, |
| 20 |
function () { return document.getElementById('example_length') != null; } |
| 21 |
); |
| 22 |
|
| 23 |
oTest.fnWaitTest( |
| 24 |
"Four default options", |
| 25 |
null, |
| 26 |
function () { return $("select[name=example_length] option").length == 4; } |
| 27 |
); |
| 28 |
|
| 29 |
oTest.fnWaitTest( |
| 30 |
"Default options", |
| 31 |
null, |
| 32 |
function () { |
| 33 |
var opts = $("select[name='example_length'] option"); |
| 34 |
return opts[0].getAttribute('value') == 10 && opts[1].getAttribute('value') == 25 && |
| 35 |
opts[2].getAttribute('value') == 50 && opts[3].getAttribute('value') == 100; |
| 36 |
} |
| 37 |
); |
| 38 |
|
| 39 |
oTest.fnWaitTest( |
| 40 |
"Info takes length into account", |
| 41 |
null, |
| 42 |
function () { return document.getElementById('example_info').innerHTML == |
| 43 |
"Showing 1 to 10 of 57 entries"; } |
| 44 |
); |
| 45 |
|
| 46 |
/* Check can disable */ |
| 47 |
oTest.fnWaitTest( |
| 48 |
"Change length can be disabled", |
| 49 |
function () { |
| 50 |
oSession.fnRestore(); |
| 51 |
$('#example').dataTable( { |
| 52 |
"sAjaxSource": "../../../examples/ajax/sources/objects.txt", |
| 53 |
"aoColumnDefs": [ |
| 54 |
{ "mData": "engine", "aTargets": [0] }, |
| 55 |
{ "mData": "browser", "aTargets": [1] }, |
| 56 |
{ "mData": "platform", "aTargets": [2] }, |
| 57 |
{ "mData": "version", "aTargets": [3] }, |
| 58 |
{ "mData": "grade", "aTargets": [4] } |
| 59 |
], |
| 60 |
"bLengthChange": false |
| 61 |
} ); |
| 62 |
}, |
| 63 |
function () { return document.getElementById('example_length') == null; } |
| 64 |
); |
| 65 |
|
| 66 |
oTest.fnWaitTest( |
| 67 |
"Information takes length disabled into account", |
| 68 |
null, |
| 69 |
function () { return document.getElementById('example_info').innerHTML == |
| 70 |
"Showing 1 to 10 of 57 entries"; } |
| 71 |
); |
| 72 |
|
| 73 |
/* Enable makes no difference */ |
| 74 |
oTest.fnWaitTest( |
| 75 |
"Length change enabled override", |
| 76 |
function () { |
| 77 |
oSession.fnRestore(); |
| 78 |
$('#example').dataTable( { |
| 79 |
"sAjaxSource": "../../../examples/ajax/sources/objects.txt", |
| 80 |
"aoColumnDefs": [ |
| 81 |
{ "mData": "engine", "aTargets": [0] }, |
| 82 |
{ "mData": "browser", "aTargets": [1] }, |
| 83 |
{ "mData": "platform", "aTargets": [2] }, |
| 84 |
{ "mData": "version", "aTargets": [3] }, |
| 85 |
{ "mData": "grade", "aTargets": [4] } |
| 86 |
], |
| 87 |
"bLengthChange": true |
| 88 |
} ); |
| 89 |
}, |
| 90 |
function () { return document.getElementById('example_length') != null; } |
| 91 |
); |
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
oTest.fnComplete(); |
| 96 |
} ); |