-
Notifications
You must be signed in to change notification settings - Fork 80
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
Search does not work for hidden columns #217
Comments
I think it is correct that invisible columns are not searched. Allowing this can confuse users. |
I understand that this may not be standard, I'm looking for a way to implement this actually. |
one workaround would be to render empty cells:
|
Hi, this is intentional and won't be changed, but I get that it can be useful in some cases. I implemented some custom filters that work on hidden columns in the Popular Movies demo. It uses Crosstalk to do the custom filtering completely outside reactable. There's no specific example of a search field that works on hidden columns, but there are similar filters that could be used as a starting point. Besides Crosstalk, the library(reactable)
library(magrittr)
htmltools::browsable(
tagList(
div(
style = "margin-bottom: 12px",
tags$input(
type = "text",
placeholder = "Search by species",
style = "padding: 4px 8px; width: 100%",
oninput = "Reactable.setFilter('iris-table', 'Species', this.value)"
)
),
iris %>%
reactable::reactable(
columns = list(Species = colDef(show = F)),
elementId = "iris-table"
)
)
) The drawback is that it only filters a single column, however. If there's enough demand for searching to work on hidden columns, it could possibly be added to reactable as a toggleable option (maybe in the JavaScript API). But I'm not a huge fan of enabling it by default because of the UX issues. If a search filter applies to a hidden column, I think that information should be visible somewhere in the table, like the genre column in the Popular Movies example. |
Thanks a lot for your comment! |
Following up on this, it's now possible to enable searching on hidden columns using a new
Here's an example of this: library(reactable)
reactable(
iris,
searchable = TRUE,
columns = list(Species = colDef(show = FALSE, searchable = TRUE))
) |
Searching does not include columns with
colDef(show = FALSE)
Yields the following:
And
Yields:
The text was updated successfully, but these errors were encountered: