select rows after search
select rows after search
montoyam
Posts: 568Questions: 136Answers: 5
Is it possible after a search is performed to select the rows that are displayed. I plan on having a button that the user will press only if they get one result from each of the dataTables on the page that will select the row in each of the tables.
I currently have a single search box that performs a search on all three.
/* search all DataTables at once */
$.fn.dataTable.ext.search.push(
function (settings, data, dataIndex) {
//console.log(settings.nTable.id);
if (settings.nTable.id == '#Departments') { return true; }
var searchFor = $('#searchFor').val().toLowerCase();
if (searchFor == undefined || searchFor == '') {
return true;
} else {
var searchItems = searchFor.split(" "); //user can hide multiple items, separated by a space
var result = false;
for (index = 0; index < searchItems.length; index++) {
if (searchItems[index]) {
if (data.toString().toLowerCase().includes(searchItems[index])) {
result = true
} else return false;
}
}
return result;
}
}
);
$('#searchFor').keyup(function () {
PhoneBookTable.draw();
StanUsersTable.draw();
FNDUsersTable.draw();
});
This discussion has been closed.
Answers
ahh, sorry, i seem to have found the solution: