/[projects]/misc/horsensspejder-web/jquery/DataTables-1.9.4/media/unit_testing/tests_onhold/3_ajax/fnRowCallback.js
ViewVC logotype

Contents of /misc/horsensspejder-web/jquery/DataTables-1.9.4/media/unit_testing/tests_onhold/3_ajax/fnRowCallback.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: 2561 byte(s)
initial import
1 // DATA_TEMPLATE: empty_table
2 oTest.fnStart( "fnRowCallback" );
3
4 /* Note - fnRowCallback MUST return the first arguments (modified or not) */
5
6 $(document).ready( function () {
7 /* Check the default */
8 var oTable = $('#example').dataTable( {
9 "sAjaxSource": "../../../examples/ajax/sources/arrays.txt"
10 } );
11 var oSettings = oTable.fnSettings();
12 var mPass;
13
14 oTest.fnWaitTest(
15 "Default should be null",
16 null,
17 function () { return oSettings.fnRowCallback == null; }
18 );
19
20
21 oTest.fnWaitTest(
22 "Four arguments passed",
23 function () {
24 oSession.fnRestore();
25
26 mPass = -1;
27 $('#example').dataTable( {
28 "sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
29 "fnRowCallback": function ( nTr ) {
30 mPass = arguments.length;
31 return nTr;
32 }
33 } );
34 },
35 function () { return mPass == 4; }
36 );
37
38
39 oTest.fnWaitTest(
40 "fnRowCallback called once for each drawn row",
41 function () {
42 oSession.fnRestore();
43
44 mPass = 0;
45 $('#example').dataTable( {
46 "sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
47 "fnRowCallback": function ( nTr, asData, iDrawIndex, iDataIndex ) {
48 mPass++;
49 return nTr;
50 }
51 } );
52 },
53 function () { return mPass == 10; }
54 );
55
56 oTest.fnWaitTest(
57 "fnRowCallback allows us to alter row information",
58 function () {
59 oSession.fnRestore();
60 $('#example').dataTable( {
61 "sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
62 "fnRowCallback": function ( nTr, asData, iDrawIndex, iDataIndex ) {
63 $(nTr).addClass('unit_test');
64 return nTr;
65 }
66 } );
67 },
68 function () { return $('#example tbody tr:eq(1)').hasClass('unit_test'); }
69 );
70
71 oTest.fnWaitTest(
72 "Data array has length matching columns",
73 function () {
74 oSession.fnRestore();
75
76 mPass = true;
77 $('#example').dataTable( {
78 "sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
79 "fnRowCallback": function ( nTr, asData, iDrawIndex, iDataIndex ) {
80 if ( asData.length != 5 )
81 mPass = false;
82 return nTr;
83 }
84 } );
85 },
86 function () { return mPass; }
87 );
88
89 oTest.fnWaitTest(
90 "Data array has length matching columns",
91 function () {
92 oSession.fnRestore();
93
94 mPass = true;
95 var iCount = 0;
96 $('#example').dataTable( {
97 "sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
98 "fnRowCallback": function ( nTr, asData, iDrawIndex, iDataIndex ) {
99 if ( iCount != iDrawIndex )
100 mPass = false;
101 iCount++;
102 return nTr;
103 }
104 } );
105 },
106 function () { return mPass; }
107 );
108
109
110
111 oTest.fnComplete();
112 } );

  ViewVC Help
Powered by ViewVC 1.1.20