Exclude Column from Search
Exclude Column from Search
JamieStanton
Posts: 4Questions: 0Answers: 0
Hi
I'm wondering if there is a way to tell DataTables to not search a certain column. I am creating a directory for shops in Dublin, but users will want to filter by Postcode (ie. Dublin 7). However at present it is also taking into account phone numbers, giving inaccurate results. Can I tall it to not filter a certain column?
Many thanks for your help
Jamie
I'm wondering if there is a way to tell DataTables to not search a certain column. I am creating a directory for shops in Dublin, but users will want to filter by Postcode (ie. Dublin 7). However at present it is also taking into account phone numbers, giving inaccurate results. Can I tall it to not filter a certain column?
Many thanks for your help
Jamie
This discussion has been closed.
Replies
See the bSearchable example here:
http://www.datatables.net/usage/columns
[code]/* Using aoColumns */
$(document).ready(function() {
$('#example').dataTable( {
"aoColumns": [
null,
null,
null,
{ "bSearchable": false }
] } );
} );[/code]
Clearly I am doing it wrong. Excuse my n00bishness as I don't' normallycode in JS / JQ.
Matthew
DataTables warning (table id = 'example'): Cannot reinitialise DataTable.
To retrieve the DataTables object for this table, please pass either no arguments to the dataTable() function, or set bRetrieve to true. Alternatively, to destory the old table and create a new one, set bDestroy to true (note that a lot of changes to the configuration can be made through the API which is usually much faster).
And the full code calling in DataTables is:
[code]
$(document).ready(function() {
$('#example').dataTable( {
"sPaginationType": "full_numbers"
} );
} );
/* Using aoColumns */
$(document).ready(function() {
$('#example').dataTable( {
"aoColumns": [
null,
null,
null,
{ "bSearchable": false }
] } );
} );
[/code]
[code]
$(document).ready(function() {
$('#example').dataTable( {
"sPaginationType": "full_numbers"
} );
} );
[/code]
and see if dataTables is happier then.