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

First option entry ignored for default search values per column #1133

Open
upgradedavid opened this issue Mar 21, 2024 · 3 comments
Open

First option entry ignored for default search values per column #1133

upgradedavid opened this issue Mar 21, 2024 · 3 comments

Comments

@upgradedavid
Copy link

upgradedavid commented Mar 21, 2024

This results in the default value of the first column Nr. 1 to be col2, instead of col1.

DT::datatable(
  cars,
  filter = "top",
  options = list(
    searchCols = list(
      list(
        search = "col1"
      ),
      list(
        search = "col2"
      ),
      list(
        search = "col3"
      ),
      list(
        search = "col4"
      )
    )
  )
)

image

R version 4.3.2 (2023-10-31 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 11 x64 (build 22631), RStudio 2023.12.1.402

Locale:
  LC_COLLATE=German_Switzerland.utf8  LC_CTYPE=German_Switzerland.utf8    LC_MONETARY=German_Switzerland.utf8
  LC_NUMERIC=C                        LC_TIME=German_Switzerland.utf8    

Package version:
  base64enc_0.1.3   bslib_0.6.1       cachem_1.0.8      cli_3.6.2         crosstalk_1.2.1   digest_0.6.35     DT_0.32          
  ellipsis_0.3.2    evaluate_0.23     fastmap_1.1.1     fontawesome_0.5.2 fs_1.6.3          glue_1.7.0        graphics_4.3.2   
  grDevices_4.3.2   highr_0.10        htmltools_0.5.7   htmlwidgets_1.6.4 httpuv_1.6.14     jquerylib_0.1.4   jsonlite_1.8.8   
  knitr_1.45        later_1.3.2       lazyeval_0.2.2    lifecycle_1.0.4   magrittr_2.0.3    memoise_2.0.1     methods_4.3.2    
  mime_0.12         promises_1.2.1    R6_2.5.1          rappdirs_0.3.3    Rcpp_1.0.12       rlang_1.1.3       rmarkdown_2.26   
  sass_0.4.9        stats_4.3.2       tinytex_0.50      tools_4.3.2       utils_4.3.2       xfun_0.42         yaml_2.3.8  
@yihui
Copy link
Member

yihui commented Mar 21, 2024

That's because the first "column" is not actually a column in the data but row names of the data. If you don't want to search the row names, you can disable them via rownames = FALSE.

@upgradedavid
Copy link
Author

upgradedavid commented Mar 21, 2024

Got it, thank you very much. I'm sorry if I'm hijacking this: When setting the search parameter initially, why does it translate into the search boxes above the columns and not just the global search box? I was trying to then using the options add caseInsensitive = T, but was unsuccessful.

DT::datatable(
  cars,
  search = list(regex = T, caseInsensitive = F),
  filter = "top",
  options = list(
    searchCols = list(
      list(
        search = NULL
      ),
      list(
        search = "col1"
      ),
      list(
        search = "col2", caseInsensitive = T
      ),
      list(
        search = "col3"
      ),
      list(
        search = "col4"
      )
    )
  )
)

@yihui
Copy link
Member

yihui commented Mar 21, 2024

The global search term needs to be set in the search element inside the options list. Example: https://rstudio.github.io/DT/007-search.html

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