1
0
mirror of https://github.com/DataTables/DataTables.git synced 2024-12-02 14:24:11 +01:00
DataTables/media/unit_testing/tests_onhold/5_ajax_objects/aoColumns.bSearchable.js

83 lines
2.4 KiB
JavaScript
Executable File

// DATA_TEMPLATE: empty_table
oTest.fnStart( "aoColumns.bSeachable" );
$(document).ready( function () {
/* Check the default */
var oTable = $('#example').dataTable( {
"sAjaxSource": "../../../examples/ajax/sources/objects.txt",
"aoColumns": [
{ "mDataSource": "engine" },
{ "mDataSource": "browser" },
{ "mDataSource": "platform" },
{ "mDataSource": "version" },
{ "mDataSource": "grade" }
]
} );
var oSettings = oTable.fnSettings();
oTest.fnWaitTest(
"Columns are searchable by default",
function () { oTable.fnFilter("Camino"); },
function () {
if ( $('#example tbody tr:eq(0) td:eq(1)')[0] )
return $('#example tbody tr:eq(0) td:eq(1)').html().match(/Camino/);
else
return null;
}
);
oTest.fnWaitTest(
"Disabling sorting on a column removes it from the global filter",
function () {
oSession.fnRestore();
oTable = $('#example').dataTable( {
"sAjaxSource": "../../../examples/ajax/sources/objects.txt",
"aoColumns": [
{ "mDataSource": "engine" },
{ "mDataSource": "browser", "bSearchable": false },
{ "mDataSource": "platform" },
{ "mDataSource": "version" },
{ "mDataSource": "grade" }
]
} );
oSettings = oTable.fnSettings();
oTable.fnFilter("Camino");
},
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == "No matching records found"; }
);
oTest.fnWaitTest(
"Disabled on one column has no effect on other columns",
function () { oTable.fnFilter("Webkit"); },
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == "Webkit"; }
);
oTest.fnWaitTest(
"Disable filtering on multiple columns",
function () {
oSession.fnRestore();
oTable = $('#example').dataTable( {
"sAjaxSource": "../../../examples/ajax/sources/objects.txt",
"aoColumns": [
{ "mDataSource": "engine", "bSearchable": false },
{ "mDataSource": "browser", "bSearchable": false },
{ "mDataSource": "platform" },
{ "mDataSource": "version" },
{ "mDataSource": "grade" }
]
} );
oSettings = oTable.fnSettings();
oTable.fnFilter("Webkit");
},
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == "No matching records found"; }
);
oTest.fnWaitTest(
"Filter on second disabled column",
function () { oTable.fnFilter("Camino"); },
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == "No matching records found"; }
);
oTest.fnComplete();
} );