1 // DATA_TEMPLATE: empty_table
2 oTest.fnStart( "aoColumns.sWidth" );
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
9 $(document).ready( function () {
10 /* Check the default */
11 var oTable = $('#example').dataTable( {
12 "sAjaxSource": "../../../examples/ajax/sources/objects.txt",
15 { "mData": "engine" },
16 { "mData": "browser", "sWidth": '40%' },
17 { "mData": "platform" },
18 { "mData": "version" },
22 var oSettings = oTable.fnSettings();
25 "With auto width disabled the width for one column is appled",
27 function () { return $('#example thead th:eq(1)')[0].style.width == "40%"; }
31 "With auto width disabled the width for one column is appled",
34 oTable = $('#example').dataTable( {
35 "sAjaxSource": "../../../examples/ajax/sources/objects.txt",
38 { "mData": "engine" },
39 { "mData": "browser" },
40 { "mData": "platform", "sWidth": '20%' },
41 { "mData": "version", "sWidth": '30%' },
48 $('#example thead th:eq(2)')[0].style.width == "20%" &&
49 $('#example thead th:eq(3)')[0].style.width == "30%";
56 "With auto width, it will make the smallest column the largest with percentage width given",
59 oTable = $('#example').dataTable( {
60 "sAjaxSource": "../../../examples/ajax/sources/objects.txt",
62 { "mData": "engine" },
63 { "mData": "browser" },
64 { "mData": "platform" },
65 { "mData": "version", "sWidth": '40%' },
71 var anThs = $('#example thead th');
72 var a0 = anThs[0].offsetWidth;
73 var a1 = anThs[1].offsetWidth;
74 var a2 = anThs[2].offsetWidth;
75 var a3 = anThs[3].offsetWidth;
76 var a4 = anThs[4].offsetWidth;
78 if ( a3>a0 && a3>a1 && a3>a2 && a3>a4 )