Skip to content

Instantly share code, notes, and snippets.

@japharr
Last active August 29, 2015 14:10
Show Gist options
  • Save japharr/3369fe85effc07e787c1 to your computer and use it in GitHub Desktop.
Save japharr/3369fe85effc07e787c1 to your computer and use it in GitHub Desktop.
Search for data, returning row indexes for jQuery DataTable 1.10
$.fn.dataTable.Api.register('cellRowIndexes()', function (sSearch, iColumn) {
var aOut = [];
if ( iColumn === undefined ) {
this.columns().iterator( 'columns', function ( settings, columns ) {
for ( var i=0, ien=columns.length ; i<ien ; i++ ) {
this.column(i).data()
.filter( function ( value, index ) {
var result = false;
if(value == sSearch) {
result = true;
aOut.push(index);
}
return result;
});
}
});
} else {
this.column(iColumn).data()
.filter( function ( value, index ) {
var result = false;
if(value == sSearch) {
result = true;
aOut.push(index);
}
return result;
});
}
return aOut;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment