pahi
pahi

Reputation: 95

R datatable function filtering manipulation

I would like to know if it is possible to turn off the datatable {DT} "filter on the fly" mode. I have filled up with so many rows and the function (HTML widget) is always try to filter once I start to type anything in the search bar. But because its a 62,000 row long table the browsers are usually freez and it takes some time to do the filtering.

My question is that is there a way to prevent the auto filtering, and lets say create a button to execute the filter once the user finishes every filtering input?

Thank you for the help!

Upvotes: 1

Views: 445

Answers (1)

Stéphane Laurent
Stéphane Laurent

Reputation: 84599

If you talk about the global search input, you can use the option search = list(return = TRUE), which allows to trigger the filtering on pressing the Enter key.

library(DT)

datatable(
  data = iris,
  options = list(
    search = list(return = TRUE)
  )
)

You can also use it with the amazing extension SearchBuilder:

datatable(
  iris,
  extensions = c("SearchBuilder", "DateTime"),
  options = list(
    dom = "Qlfrtip",
    searchBuilder = TRUE,
    search = list(return = TRUE)
  )
)

This is a GIF showing the search builder but without the search = list(return = TRUE) option:

enter image description here

Upvotes: 1

Related Questions