Clearing column searches for all but one column

Clearing column searches for all but one column

YOMYOM Posts: 53Questions: 22Answers: 1

Hey there,

I'm trying to clear the search value for all columns except for one.

// Clearing column searches in datatables API (Control)
dt.columns(function (idx, data, node) {
  const col = columns[idx];
  return col.data !== "column_name"; // Clear all but column_name
})
  .search("")
  .draw();

This doesn't appear to be working as expected. Any help is appreciated, thank you!

Answers

  • YOMYOM Posts: 53Questions: 22Answers: 1

    Ah apologies, I realize now the issue is being caused by our application modifying columns in a separate area to "filter" the columns being shown, so the indexes are off. This code does in fact work

    Please feel free to close this question

Sign In or Register to comment.