Skip to content

Move search fields too when reordering headers #940

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions run_dir/design/ont_flowcells.html
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,25 @@ <h1>
<!-- ONT Table Sorting -->
<script type="text/javascript">
$( document ).ready(function() {
init_listjs_ont();
var table = init_listjs_ont();
initColumnSearch(table);
table.on('column-reorder', function (e, settings, details) {
let footer = $('#ont_fc_table tfoot tr');
let inputs = footer.find('input').detach(); // Detach all inputs
// Clear footer
footer.empty();
// Rebuild footer row based on new column order
const tab = new $.fn.dataTable.Api(settings);
tab.columns().every(function (i) {
let th = $('<th></th>');
let input = $(inputs[details.mapping[i]] || $('<input type="text" />')); // Preserve existing input if possible
let headertext =$(tab.column(i).header()).text();
input.attr('placeholder', `Search ${headertext}`);
th.append(input);
footer.append(th);
});
initColumnSearch(tab); // Re-bind search
});
});
// Initialize sorting and searching javascript plugin
function init_listjs_ont() {
Expand Down Expand Up @@ -266,7 +284,10 @@ <h1>
$('#ont_fc_table_filter label').remove();
$("#ont_fc_table_filter input").attr("placeholder", "Search..");

// Apply the search
return table;
}

function initColumnSearch(table) {
table.columns().every( function () {
var that = this;
$( 'input', this.footer() ).on( 'keyup change', function () {
Expand Down