Last active
August 29, 2015 14:10
-
-
Save japharr/3369fe85effc07e787c1 to your computer and use it in GitHub Desktop.
Search for data, returning row indexes for jQuery DataTable 1.10
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.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