1 |
// DATA_TEMPLATE: empty_table |
2 |
oTest.fnStart( "aoColumns.fnRender" ); |
3 |
|
4 |
$(document).ready( function () { |
5 |
/* Check the default */ |
6 |
var mTmp = 0; |
7 |
var oTable = $('#example').dataTable( { |
8 |
"bServerSide": true, |
9 |
"sAjaxSource": "../../../examples/server_side/scripts/server_processing.php", |
10 |
"aoColumns": [ |
11 |
null, |
12 |
{ "fnRender": function (a) { |
13 |
mTmp++; |
14 |
return a.aData[a.iDataColumn]; |
15 |
} }, |
16 |
null, |
17 |
null, |
18 |
null |
19 |
] |
20 |
} ); |
21 |
var oSettings = oTable.fnSettings(); |
22 |
|
23 |
oTest.fnWaitTest( |
24 |
"Single column - fnRender is called once for each row", |
25 |
null, |
26 |
function () { return mTmp == 10; } |
27 |
); |
28 |
|
29 |
oTest.fnWaitTest( |
30 |
"Confirm that fnRender passes two arguments with four parameters", |
31 |
function () { |
32 |
mTmp = true; |
33 |
oSession.fnRestore(); |
34 |
oTable = $('#example').dataTable( { |
35 |
"bServerSide": true, |
36 |
"sAjaxSource": "../../../examples/server_side/scripts/server_processing.php", |
37 |
"aoColumns": [ |
38 |
null, |
39 |
{ "fnRender": function (a) { |
40 |
if ( arguments.length != 2 || typeof a.iDataRow=='undefined' || |
41 |
typeof a.iDataColumn=='undefined' || typeof a.aData=='undefined' || |
42 |
typeof a.mDataProp=='undefined' ) |
43 |
{ |
44 |
mTmp = false; |
45 |
} |
46 |
return a.aData[a.iDataColumn]; |
47 |
} }, |
48 |
null, |
49 |
null, |
50 |
null |
51 |
] |
52 |
} ); |
53 |
}, |
54 |
function () { return mTmp; } |
55 |
); |
56 |
|
57 |
oTest.fnWaitTest( |
58 |
"fnRender iDataColumn is the column", |
59 |
function () { |
60 |
mTmp = true; |
61 |
oSession.fnRestore(); |
62 |
oTable = $('#example').dataTable( { |
63 |
"bServerSide": true, |
64 |
"sAjaxSource": "../../../examples/server_side/scripts/server_processing.php", |
65 |
"aoColumns": [ |
66 |
null, |
67 |
{ "fnRender": function (a) { |
68 |
if ( a.iDataColumn != 1 ) |
69 |
{ |
70 |
mTmp = false; |
71 |
} |
72 |
return a.aData[a.iDataColumn]; |
73 |
} }, |
74 |
null, |
75 |
null, |
76 |
null |
77 |
] |
78 |
} ); |
79 |
}, |
80 |
function () { return mTmp; } |
81 |
); |
82 |
|
83 |
oTest.fnWaitTest( |
84 |
"fnRender aData is data array of correct size", |
85 |
function () { |
86 |
mTmp = true; |
87 |
oSession.fnRestore(); |
88 |
oTable = $('#example').dataTable( { |
89 |
"bServerSide": true, |
90 |
"sAjaxSource": "../../../examples/server_side/scripts/server_processing.php", |
91 |
"aoColumns": [ |
92 |
null, |
93 |
{ "fnRender": function (a) { |
94 |
if ( a.aData.length != 5 ) |
95 |
{ |
96 |
mTmp = false; |
97 |
} |
98 |
return a.aData[a.iDataColumn]; |
99 |
} }, |
100 |
null, |
101 |
null, |
102 |
null |
103 |
] |
104 |
} ); |
105 |
}, |
106 |
function () { return mTmp; } |
107 |
); |
108 |
|
109 |
oTest.fnWaitTest( |
110 |
"Passed back data is put into the DOM", |
111 |
function () { |
112 |
oSession.fnRestore(); |
113 |
oTable = $('#example').dataTable( { |
114 |
"bServerSide": true, |
115 |
"sAjaxSource": "../../../examples/server_side/scripts/server_processing.php", |
116 |
"aoColumns": [ |
117 |
null, |
118 |
{ "fnRender": function (a) { |
119 |
return 'unittest'; |
120 |
} }, |
121 |
null, |
122 |
null, |
123 |
null |
124 |
] |
125 |
} ); |
126 |
}, |
127 |
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == 'unittest'; } |
128 |
); |
129 |
|
130 |
oTest.fnWaitTest( |
131 |
"Passed back data is put into the DOM", |
132 |
function () { |
133 |
oSession.fnRestore(); |
134 |
oTable = $('#example').dataTable( { |
135 |
"bServerSide": true, |
136 |
"sAjaxSource": "../../../examples/server_side/scripts/server_processing.php", |
137 |
"aoColumns": [ |
138 |
null, |
139 |
null, |
140 |
{ "fnRender": function (a) { |
141 |
return 'unittest1'; |
142 |
} }, |
143 |
{ "fnRender": function (a) { |
144 |
return 'unittest2'; |
145 |
} }, |
146 |
null |
147 |
] |
148 |
} ); |
149 |
}, |
150 |
function () { |
151 |
var bReturn = |
152 |
$('#example tbody tr:eq(0) td:eq(2)').html() == 'unittest1' && |
153 |
$('#example tbody tr:eq(0) td:eq(3)').html() == 'unittest2'; |
154 |
return bReturn; } |
155 |
); |
156 |
|
157 |
|
158 |
|
159 |
|
160 |
|
161 |
oTest.fnComplete(); |
162 |
} ); |