Skip to content
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

Interaction between searching options parameter and datatable::filter #1142

Open
3 tasks done
keatonwilson opened this issue Jun 11, 2024 · 2 comments
Open
3 tasks done

Comments

@keatonwilson
Copy link

Problem

We recently encountered an issue when trying to create a table that has column-based filters but no table-wide search bar. Our initial approach was to create a table like the one below:

# Create a table
palmerpenguins::penguins |> 
  DT::datatable(
    options = list(
      # Turn off top table-wide search bar
      searching = FALSE
    ), 
    # Set filters to above columns
    filter = "top"
    )

This successfully creates a table, but the column filters don't work. After some forum searching, we opted for an approach where we set searching = TRUE and then hide the full-table search bar via CSS:

.dataTables_filter {
  display: none;
}

This works, but wondering if other users may run into the same issue - we didn't find any documentation around the interaction between these two parameters. Ideally, it would be a great to get some kind of warning indicating that column filters will display, but they're not functional in this situation - perhaps we missed it in our reading!

Thanks in advance!

Session Info

R version 4.4.0 (2024-04-24)
Platform: x86_64-pc-linux-gnu
Running under: Red Hat Enterprise Linux 8.10 (Ootpa), RStudio 2024.4.1.748.2


Locale:
  LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8       
  LC_COLLATE=en_US.UTF-8     LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
  LC_PAPER=en_US.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
  LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

time zone: America/New_York
tzcode source: system (glibc)

Package version:
  base64enc_0.1.3   bslib_0.5.1       cachem_1.0.8      cli_3.6.1        
  crosstalk_1.2.0   digest_0.6.33     DT_0.31           ellipsis_0.3.2   
  evaluate_0.21     fastmap_1.1.1     fontawesome_0.5.2 fs_1.6.3         
  glue_1.6.2        graphics_4.4.0    grDevices_4.4.0   highr_0.10       
  htmltools_0.5.6   htmlwidgets_1.6.2 httpuv_1.6.11     jquerylib_0.1.4  
  jsonlite_1.8.7    knitr_1.43        later_1.3.1       lazyeval_0.2.2   
  lifecycle_1.0.3   magrittr_2.0.3    memoise_2.0.1     methods_4.4.0    
  mime_0.12         promises_1.2.1    R6_2.5.1          rappdirs_0.3.3   
  Rcpp_1.0.11       rlang_1.1.1       rmarkdown_2.24    sass_0.4.7       
  stats_4.4.0       stringi_1.7.12    stringr_1.5.0     tinytex_0.46     
  tools_4.4.0       utils_4.4.0       vctrs_0.6.3       xfun_0.40        
  yaml_2.3.7 

By filing an issue to this repo, I promise that

  • I have fully read the issue guide at https://yihui.org/issue/.
  • I have provided the necessary information about my issue.
    • If I'm asking a question, I have already asked it on Stack Overflow or RStudio Community, waited for at least 24 hours, and included a link to my question there.
    • If I'm filing a bug report, I have included a minimal, self-contained, and reproducible example, and have also included xfun::session_info('DT'). I have upgraded all my packages to their latest versions (e.g., R, RStudio, and R packages), and also tried the development version: remotes::install_github('rstudio/DT').
    • If I have posted the same issue elsewhere, I have also mentioned it in this issue.
  • I have learned the Github Markdown syntax, and formatted my issue correctly.

I understand that my issue may be closed if I don't fulfill my promises.

@philibe
Copy link

philibe commented Jun 12, 2024

We have to drop f from dom options:

palmerpenguins::penguins |> 
  DT::datatable(
    # Set filters to above columns
    filter = "top",
    options = list(
      # drop f from dom
      dom = 'ltpir',
      # do not disable searching
      searching = TRUE
    )
  )

https://datatables.net/reference/option/dom:

  • l - length changing input control
  • f - filtering input
  • t - The table!
  • i - Table information summary
  • p - pagination control
  • r - processing display element

I understand now the contradictions in the datatable.net documentation (DT is on DataTables 1.10). I use for many years dom.

Define the table control elements to appear on the page and in what order. Since: DataTables 1.10
Deprecated!

As of v2.0 this feature has been deprecated. This feature will be removed from version 3.0.

This option is superseded by the layout option in DataTables 2, which is far more flexible, intuitive and styling framework independent. Do not use this option for new projects, and actively update older projects to use layout rather than this option.

@keatonwilson
Copy link
Author

Thanks @philibe - appreciate the reply and documentation on the dom parameter - that's not something we've used extensively before, but very useful!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants