Exclude data from sort
Exclude data from sort
Is it possible to Exclude certain data from sorting?
example:
I have a column of titles and names, eg: Mr Peter Parker, Miss Lois Lane, Mr Bruce Wane etc..
The data is served from a DB so I cannot modify it.
Can I choose to exclude Mr, Mrs, Miss etc so I can sort the column by first name?
Many thanks for any response in advance.
example:
I have a column of titles and names, eg: Mr Peter Parker, Miss Lois Lane, Mr Bruce Wane etc..
The data is served from a DB so I cannot modify it.
Can I choose to exclude Mr, Mrs, Miss etc so I can sort the column by first name?
Many thanks for any response in advance.
This discussion has been closed.
Replies
http://www.datatables.net/ref
[code]
/* Using aoColumnDefs */
$(document).ready(function() {
$('#example').dataTable( {
"aoColumnDefs": [
{ "bSearchable": false, "aTargets": [ 0 ] }
] } );
} );
/* Using aoColumns */
$(document).ready(function() {
$('#example').dataTable( {
"aoColumns": [
{ "bSearchable": false },
null,
null,
null,
null
] } );
} );
[/code]
I think what I'm looking for is some sort of filter option to exclude Mr, Mrs etc from that column's sorting, whilst still displaying it.
[code]
/* Using aoColumnDefs */
$(document).ready(function() {
$('#example').dataTable( {
"aoColumnDefs": [
{
"aTargets": [ 0 ]
"fnRender": function (oObj) {
var val = oObj.aData[oObj.iDataColumn]; // get the data of this cell
val = replace('/^[Mm]rs?\.? +/', '');
val = replace('/^[Mm]iss +/', '');
return val; // this is super important. must return string val that becomes the new cell value
}
}
] } );
} );
[/code]
something like that.