Free cookie consent management tool by TermsFeed Policy Generator

source: branches/WebApplication/MVC2/HeuristicLabWeb.PluginHost/HLWebPluginHost/Content/jQuery/jQueryPlugins/DataTables-1.7.6/media/unit_testing/tests_onhold/2_js/aoColumns.sWidth.js @ 6286

Last change on this file since 6286 was 6286, checked in by dkahn, 13 years ago

#1198 Added jQuery plus plugins

File size: 1.9 KB
Line 
1// DATA_TEMPLATE: js_data
2oTest.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    "aaData": gaaData,
13    "bAutoWidth": false,
14    "aoColumns": [
15      null,
16      { "sWidth": '40%' },
17      null,
18      null,
19      null
20    ]
21  } );
22  var oSettings = oTable.fnSettings();
23 
24  oTest.fnTest(
25    "With auto width disabled the width for one column is appled",
26    null,
27    function () { return $('#example thead th:eq(1)')[0].style.width == "40%"; }
28  );
29 
30  oTest.fnTest(
31    "With auto width disabled the width for one column is appled",
32    function () {
33      oSession.fnRestore();
34      oTable = $('#example').dataTable( {
35        "aaData": gaaData,
36        "bAutoWidth": false,
37        "aoColumns": [
38          null,
39          null,
40          { "sWidth": '20%' },
41          { "sWidth": '30%' },
42          null
43        ]
44      } );
45    },
46    function () {
47      var bReturn =
48        $('#example thead th:eq(2)')[0].style.width == "20%" &&
49        $('#example thead th:eq(3)')[0].style.width == "30%";
50      return bReturn;
51    }
52  );
53 
54 
55  oTest.fnTest(
56    "With auto width, it will make the smallest column the largest with percentage width given",
57    function () {
58      oSession.fnRestore();
59      oTable = $('#example').dataTable( {
60        "aaData": gaaData,
61        "aoColumns": [
62          null,
63          null,
64          null,
65          { "sWidth": '40%' },
66          null
67        ]
68      } );
69    },
70    function () {
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;
77     
78      if ( a3>a0 && a3>a1 && a3>a2 && a3>a4 )
79        return true;
80      else
81        return false;
82    }
83  );
84 
85 
86  oTest.fnComplete();
87} );
Note: See TracBrowser for help on using the repository browser.