1 |
// DATA_TEMPLATE: empty_table |
2 |
oTest.fnStart( "aoSearchCols" ); |
3 |
|
4 |
/* We could be here forever testing this one, so we test a limited subset on a couple of colums */ |
5 |
|
6 |
$(document).ready( function () { |
7 |
/* Check the default */ |
8 |
var oTable = $('#example').dataTable( { |
9 |
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt", |
10 |
"bDeferRender": true |
11 |
} ); |
12 |
var oSettings = oTable.fnSettings(); |
13 |
|
14 |
oTest.fnWaitTest( |
15 |
"Default should be to have a empty colums array", |
16 |
null, |
17 |
function () { |
18 |
var bReturn = |
19 |
oSettings.aoPreSearchCols[0].sSearch == 0 && !oSettings.aoPreSearchCols[0].bRegex && |
20 |
oSettings.aoPreSearchCols[1].sSearch == 0 && !oSettings.aoPreSearchCols[1].bRegex && |
21 |
oSettings.aoPreSearchCols[2].sSearch == 0 && !oSettings.aoPreSearchCols[2].bRegex && |
22 |
oSettings.aoPreSearchCols[3].sSearch == 0 && !oSettings.aoPreSearchCols[3].bRegex && |
23 |
oSettings.aoPreSearchCols[4].sSearch == 0 && !oSettings.aoPreSearchCols[4].bRegex; |
24 |
return bReturn; |
25 |
} |
26 |
); |
27 |
|
28 |
|
29 |
oTest.fnWaitTest( |
30 |
"Search on a single column - no regex statement given", |
31 |
function () { |
32 |
oSession.fnRestore(); |
33 |
oTable = $('#example').dataTable( { |
34 |
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt", |
35 |
"bDeferRender": true, |
36 |
"aoSearchCols": [ |
37 |
null, |
38 |
{ "sSearch": "Mozilla" }, |
39 |
null, |
40 |
{ "sSearch": "1" }, |
41 |
null |
42 |
] |
43 |
} ); |
44 |
}, |
45 |
function () { return $('#example_info').html() == "Showing 1 to 9 of 9 entries (filtered from 57 total entries)"; } |
46 |
); |
47 |
|
48 |
oTest.fnWaitTest( |
49 |
"Search on two columns - no regex statement given", |
50 |
function () { |
51 |
oSession.fnRestore(); |
52 |
oTable = $('#example').dataTable( { |
53 |
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt", |
54 |
"bDeferRender": true, |
55 |
"aoSearchCols": [ |
56 |
null, |
57 |
{ "sSearch": "Mozilla" }, |
58 |
null, |
59 |
{ "sSearch": "1.5" }, |
60 |
null |
61 |
] |
62 |
} ); |
63 |
}, |
64 |
function () { return $('#example tbody tr:eq(0) td:eq(3)').html() == "1.5"; } |
65 |
); |
66 |
|
67 |
oTest.fnWaitTest( |
68 |
"Search on single column - escape regex false", |
69 |
function () { |
70 |
oSession.fnRestore(); |
71 |
oTable = $('#example').dataTable( { |
72 |
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt", |
73 |
"bDeferRender": true, |
74 |
"aoSearchCols": [ |
75 |
{ "sSearch": ".*ML", "bEscapeRegex": false }, |
76 |
null, |
77 |
null, |
78 |
null, |
79 |
null |
80 |
] |
81 |
} ); |
82 |
}, |
83 |
function () { return $('#example_info').html() == "Showing 1 to 3 of 3 entries (filtered from 57 total entries)"; } |
84 |
); |
85 |
|
86 |
oTest.fnWaitTest( |
87 |
"Search on two columns - escape regex false on first, true on second", |
88 |
function () { |
89 |
oSession.fnRestore(); |
90 |
oTable = $('#example').dataTable( { |
91 |
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt", |
92 |
"bDeferRender": true, |
93 |
"aoSearchCols": [ |
94 |
{ "sSearch": ".*ML", "bEscapeRegex": false }, |
95 |
{ "sSearch": "3.3", "bEscapeRegex": true }, |
96 |
null, |
97 |
null, |
98 |
null |
99 |
] |
100 |
} ); |
101 |
}, |
102 |
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == "Konqureror 3.3"; } |
103 |
); |
104 |
|
105 |
oTest.fnWaitTest( |
106 |
"Search on two columns (no records) - escape regex false on first, true on second", |
107 |
function () { |
108 |
oSession.fnRestore(); |
109 |
oTable = $('#example').dataTable( { |
110 |
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt", |
111 |
"bDeferRender": true, |
112 |
"aoSearchCols": [ |
113 |
{ "sSearch": ".*ML", "bEscapeRegex": false }, |
114 |
{ "sSearch": "Allan", "bEscapeRegex": true }, |
115 |
null, |
116 |
null, |
117 |
null |
118 |
] |
119 |
} ); |
120 |
}, |
121 |
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == "No matching records found"; } |
122 |
); |
123 |
|
124 |
oTest.fnComplete(); |
125 |
} ); |