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

Change SearchPanes Button text? #804

Closed
3 tasks done
mfherman opened this issue Apr 28, 2020 · 6 comments
Closed
3 tasks done

Change SearchPanes Button text? #804

mfherman opened this issue Apr 28, 2020 · 6 comments
Labels
Milestone

Comments

@mfherman
Copy link

I'm using the new SeachPanes feature from DT along with the Buttons extension and I'm having trouble changing the text displayed on the SearchPanes button.

For other buttons, I can change the button text by using the text argument, but when I try this for SearchPanes, I can't change the text. See below for an example where I change the text of the Copy button to "Hi!", but the same does not work with the SearchPanes button.

library(DT)

datatable(
 iris,
 options = list(
   dom = 'Bfrtip',
   columnDefs = list(list(searchPanes = list(show = FALSE), targets = 1:4)),
   buttons = list(
     list(extend = "searchPanes", text = "Filter"),
     list(extend = "copy", text = "Hi!"))
   ),
 extensions = c('Select', 'SearchPanes', 'Buttons')
)

KAr3VQg

This was posted on RStudio Community but has not received any answers.


By filing an issue to this repo, I promise that

  • I have fully read the issue guide at https://yihui.name/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.

@shrektan
Copy link
Collaborator

shrektan commented Apr 28, 2020

According to the example on datatables's official site, you should use language.searchPanes.collapse.

library(DT)

datatable(
  iris,
  options = list(
    dom = 'Bfrtip',
    columnDefs = list(list(searchPanes = list(show = FALSE), targets = 1:4)),
    buttons = list(
      'searchPanes',
      list(extend = "copy", text = "Hi!")),
    language = list(searchPanes = list(collapse = 'filter'))
  ),
  extensions = c('Select', 'SearchPanes', 'Buttons')
)

@shrektan shrektan added this to the v0.14 milestone Apr 28, 2020
@mfherman
Copy link
Author

Ah - my oversight. Thank you so much for the clarification!

@mfherman
Copy link
Author

I think this is also a simple question, but I don't see it in the documentation: where can I set other options for the searchPanes extension. For example to turn off all controls I thought I could add the following to options as described in the datatables documentation. My apologies if this is documented elsewhere!

datatable(
  iris,
  options = list(
    dom = 'Bfrtip',
    columnDefs = list(list(searchPanes = list(show = FALSE), targets = 1:4)),
    buttons = list(
      'searchPanes',
      list(extend = "copy", text = "Hi!")),
    language = list(searchPanes = list(collapse = 'filter')),
    searchPanes = list(controls = FALSE)
  ),
  extensions = c('Select', 'SearchPanes', 'Buttons')
)

@shrektan
Copy link
Collaborator

shrektan commented Apr 28, 2020

I don't see it's documented. But it seems that when using searchPanes Buttons, you need to set the controls via columns.searchPanes.controls.

So this works:

library(DT)
datatable(
  iris,
  options = list(
    dom = 'Bfrtip',
    columnDefs = list(
      list(searchPanes = list(show = FALSE), targets = 1:4),
      list(searchPanes = list(controls = FALSE), targets = 5)
    ),
    buttons = list(
      'searchPanes',
      list(extend = "copy", text = "Hi!")
    ),
    language = list(searchPanes = list(collapse = 'filter'))
  ),
  extensions = c('Select', 'SearchPanes', 'Buttons')
)

@mfherman
Copy link
Author

Thank you again @shrektan!

@mfherman
Copy link
Author

I wrote up a little blog post demonstrating some of these options. Might be useful in anyone comes across this issue!

https://mattherman.info/blog/dt_searchpanes/

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

No branches or pull requests

2 participants