annotate DataTables-1.9.4/media/unit_testing/tests_onhold/6_delayed_rendering/aoColumns.sWidth.js @ 9:7300ed4c1481 draft default tip

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