1 |
// DATA_TEMPLATE: empty_table |
2 |
oTest.fnStart( "aoColumns.sWidth" ); |
3 |
|
4 |
/* NOTE - we need to disable the auto width for the majority of these test in order to preform |
5 |
* these tests as the auto width will convert the width to a px value. We can do 'non-exact' tests |
6 |
* with auto width enabled however to ensure it scales columns as required |
7 |
*/ |
8 |
|
9 |
$(document).ready( function () { |
10 |
/* Check the default */ |
11 |
var oTable = $('#example').dataTable( { |
12 |
"bServerSide": true, |
13 |
"sAjaxSource": "../../../examples/server_side/scripts/server_processing.php", |
14 |
"bAutoWidth": false, |
15 |
"aoColumns": [ |
16 |
null, |
17 |
{ "sWidth": '40%' }, |
18 |
null, |
19 |
null, |
20 |
null |
21 |
] |
22 |
} ); |
23 |
var oSettings = oTable.fnSettings(); |
24 |
|
25 |
oTest.fnWaitTest( |
26 |
"With auto width disabled the width for one column is appled", |
27 |
null, |
28 |
function () { return $('#example thead th:eq(1)')[0].style.width == "40%"; } |
29 |
); |
30 |
|
31 |
oTest.fnWaitTest( |
32 |
"With auto width disabled the width for one column is appled", |
33 |
function () { |
34 |
oSession.fnRestore(); |
35 |
oTable = $('#example').dataTable( { |
36 |
"bServerSide": true, |
37 |
"sAjaxSource": "../../../examples/server_side/scripts/server_processing.php", |
38 |
"bAutoWidth": false, |
39 |
"aoColumns": [ |
40 |
null, |
41 |
null, |
42 |
{ "sWidth": '20%' }, |
43 |
{ "sWidth": '30%' }, |
44 |
null |
45 |
] |
46 |
} ); |
47 |
}, |
48 |
function () { |
49 |
var bReturn = |
50 |
$('#example thead th:eq(2)')[0].style.width == "20%" && |
51 |
$('#example thead th:eq(3)')[0].style.width == "30%"; |
52 |
return bReturn; |
53 |
} |
54 |
); |
55 |
|
56 |
|
57 |
oTest.fnWaitTest( |
58 |
"With auto width, it will make the smallest column the largest with percentage width given", |
59 |
function () { |
60 |
oSession.fnRestore(); |
61 |
oTable = $('#example').dataTable( { |
62 |
"bServerSide": true, |
63 |
"sAjaxSource": "../../../examples/server_side/scripts/server_processing.php", |
64 |
"aoColumns": [ |
65 |
null, |
66 |
null, |
67 |
null, |
68 |
{ "sWidth": '40%' }, |
69 |
null |
70 |
] |
71 |
} ); |
72 |
}, |
73 |
function () { |
74 |
var anThs = $('#example thead th'); |
75 |
var a0 = anThs[0].offsetWidth; |
76 |
var a1 = anThs[1].offsetWidth; |
77 |
var a2 = anThs[2].offsetWidth; |
78 |
var a3 = anThs[3].offsetWidth; |
79 |
var a4 = anThs[4].offsetWidth; |
80 |
|
81 |
if ( a3>a0 && a3>a1 && a3>a2 && a3>a4 ) |
82 |
return true; |
83 |
else |
84 |
return false; |
85 |
} |
86 |
); |
87 |
|
88 |
|
89 |
oTest.fnComplete(); |
90 |
} ); |