annotate DataTables-1.9.4/media/unit_testing/tests_onhold/6_delayed_rendering/aoColumns.bUseRendered.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.bUseRendered" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4 /* bUseRendered is used to alter sorting data, if false then the original data is used for
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5 * sorting rather than the rendered data
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8 $(document).ready( function () {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9 /* Check the default */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10 var mTmp = 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12 var oTable = $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
13 "sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
14 "bDeferRender": true,
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 { "fnRender": function (a) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
18 if ( a.iDataRow == 0 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
19 mTmp++;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
20 return "aaa";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
21 } else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
22 return a.aData[a.iDataColumn];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
23 } },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
24 null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
25 null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
26 null
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
27 ]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
28 } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
29 var oSettings = oTable.fnSettings();
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 "Default for bUseRendered is true - rendered data is used for sorting",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
33 function () { $('#example thead th:eq(1)').click(); },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
34 function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == 'aaa'; }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
35 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
36
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
37 oTest.fnWaitTest(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
38 "When bUseRendered is false, original data is used for sorting",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
39 function () {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
40 mTmp = 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
41 oSession.fnRestore();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
42 oTable = $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
43 "sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
44 "bDeferRender": true,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
45 "aoColumns": [
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
46 null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
47 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
48 "bUseRendered": false,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
49 "fnRender": function (a) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
50 if ( a.iDataRow == 0 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
51 mTmp++;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
52 return "aaa";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
53 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
54 return a.aData[a.iDataColumn];
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 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
58 null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
59 null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
60 null
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
61 ]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
62 } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
63 $('#example thead th:eq(1)').click();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
64 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
65 function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == 'All others'; }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
66 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
67
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
68
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
69 oTest.fnWaitTest(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
70 "bUseRendered set to false on one columns and true (default) on two others",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
71 function () {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
72 mTmp = 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
73 var mTmp2 = 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
74 var mTmp3 = 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
75
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
76 oSession.fnRestore();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
77 oTable = $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
78 "sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
79 "bDeferRender": true,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
80 "aoColumns": [
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
81 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
82 "fnRender": function (a) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
83 if ( a.iDataRow == 0 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
84 mTmp++;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
85 return "aaa1";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
86 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
87 return a.aData[a.iDataColumn];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
88 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
89 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
90 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
91 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
92 "bUseRendered": false,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
93 "fnRender": function (a) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
94 if ( a.iDataRow == 0 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
95 mTmp2++;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
96 return "aaa2";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
97 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
98 return a.aData[a.iDataColumn];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
99 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
100 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
101 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
102 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
103 "fnRender": function (a) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
104 if ( a.iDataRow == 0 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
105 mTmp3++;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
106 return "zzz3";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
107 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
108 return a.aData[a.iDataColumn];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
109 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
110 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
111 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
112 null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
113 null
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
114 ]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
115 } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
116 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
117 function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == 'aaa1'; }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
118 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
119
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
120 oTest.fnWaitTest(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
121 "Multi-column rendering - 2nd column sorting",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
122 function () { $('#example thead th:eq(1)').click(); },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
123 function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == 'All others'; }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
124 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
125
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
126 oTest.fnWaitTest(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
127 "Multi-column rendering - 3rd column sorting",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
128 function () {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
129 $('#example thead th:eq(2)').click();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
130 $('#example thead th:eq(2)').click();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
131 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
132 function () { return $('#example tbody tr:eq(0) td:eq(2)').html() == 'zzz3'; }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
133 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
134
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
135 oTest.fnWaitTest(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
136 "Multi-column rendering - 4th column sorting",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
137 function () { $('#example thead th:eq(3)').click(); },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
138 function () { return $('#example tbody tr:eq(0) td:eq(3)').html() == '-'; }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
139 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
140
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
141 oTest.fnWaitTest(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
142 "Multi-column rendering - 5th column sorting",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
143 function () { $('#example thead th:eq(4)').click(); },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
144 function () { return $('#example tbody tr:eq(0) td:eq(4)').html() == 'A'; }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
145 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
146
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
147
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
148
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
149
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
150 oTest.fnComplete();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
151 } );