/[projects]/misc/horsensspejder-web/jquery/DataTables-1.9.4/media/unit_testing/tests_onhold/2_js/aoColumns.bUseRendered.js
ViewVC logotype

Contents of /misc/horsensspejder-web/jquery/DataTables-1.9.4/media/unit_testing/tests_onhold/2_js/aoColumns.bUseRendered.js

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2125 - (show annotations) (download) (as text)
Wed Mar 12 19:30:05 2014 UTC (10 years, 3 months ago) by torben
File MIME type: application/javascript
File size: 3350 byte(s)
initial import
1 // DATA_TEMPLATE: js_data
2 oTest.fnStart( "aoColumns.bUseRendered" );
3
4 /* bUseRendered is used to alter sorting data, if false then the original data is used for
5 * sorting rather than the rendered data
6 */
7
8 $(document).ready( function () {
9 /* Check the default */
10 var mTmp = 0;
11
12 var oTable = $('#example').dataTable( {
13 "aaData": gaaData,
14 "aoColumns": [
15 null,
16 { "fnRender": function (a) {
17 if ( mTmp == 0 ) {
18 mTmp++;
19 return "aaa";
20 } else
21 return a.aData[a.iDataColumn];
22 } },
23 null,
24 null,
25 null
26 ]
27 } );
28 var oSettings = oTable.fnSettings();
29
30 oTest.fnTest(
31 "Default for bUseRendered is true - rendered data is used for sorting",
32 function () { $('#example thead th:eq(1)').click(); },
33 function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == 'aaa'; }
34 );
35
36 oTest.fnTest(
37 "When bUseRendered is false, original data is used for sorting",
38 function () {
39 mTmp = 0;
40 oSession.fnRestore();
41 oTable = $('#example').dataTable( {
42 "aaData": gaaData,
43 "aoColumns": [
44 null,
45 {
46 "bUseRendered": false,
47 "fnRender": function (a) {
48 if ( mTmp == 0 ) {
49 mTmp++;
50 return "aaa";
51 } else {
52 return a.aData[a.iDataColumn];
53 }
54 }
55 },
56 null,
57 null,
58 null
59 ]
60 } );
61 $('#example thead th:eq(1)').click();
62 },
63 function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == 'All others'; }
64 );
65
66
67 oTest.fnTest(
68 "bUseRendered set to false on one columns and true (default) on two others",
69 function () {
70 mTmp = 0;
71 var mTmp2 = 0;
72 var mTmp3 = 0;
73
74 oSession.fnRestore();
75 oTable = $('#example').dataTable( {
76 "aaData": gaaData,
77 "aoColumns": [
78 {
79 "fnRender": function (a) {
80 if ( mTmp == 0 ) {
81 mTmp++;
82 return "aaa1";
83 } else {
84 return a.aData[a.iDataColumn];
85 }
86 }
87 },
88 {
89 "bUseRendered": false,
90 "fnRender": function (a) {
91 if ( mTmp2 == 0 ) {
92 mTmp2++;
93 return "aaa2";
94 } else {
95 return a.aData[a.iDataColumn];
96 }
97 }
98 },
99 {
100 "fnRender": function (a) {
101 if ( mTmp3 == 0 ) {
102 mTmp3++;
103 return "zzz3";
104 } else {
105 return a.aData[a.iDataColumn];
106 }
107 }
108 },
109 null,
110 null
111 ]
112 } );
113 },
114 function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == 'aaa1'; }
115 );
116
117 oTest.fnTest(
118 "Multi-column rendering - 2nd column sorting",
119 function () { $('#example thead th:eq(1)').click(); },
120 function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == 'All others'; }
121 );
122
123 oTest.fnTest(
124 "Multi-column rendering - 3rd column sorting",
125 function () {
126 $('#example thead th:eq(2)').click();
127 $('#example thead th:eq(2)').click();
128 },
129 function () { return $('#example tbody tr:eq(0) td:eq(2)').html() == 'zzz3'; }
130 );
131
132 oTest.fnTest(
133 "Multi-column rendering - 4th column sorting",
134 function () { $('#example thead th:eq(3)').click(); },
135 function () { return $('#example tbody tr:eq(0) td:eq(3)').html() == '-'; }
136 );
137
138 oTest.fnTest(
139 "Multi-column rendering - 5th column sorting",
140 function () { $('#example thead th:eq(4)').click(); },
141 function () { return $('#example tbody tr:eq(0) td:eq(4)').html() == 'A'; }
142 );
143
144
145
146
147 oTest.fnComplete();
148 } );

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.20