0

I'm trying to incorporate something like this: https://infra.clarin.eu/content/libs/DataTables-1.10.6/examples/api/show_hide.html into my R Shiny application.

I'm unfamiliar with how to incorporate the JS into R, but showing/hiding columns doesn't necessarily need to function like this. It could be a drop down (selectInput) with the column headers where the user could select multiple choices in order to hide those specific columns. Or even check boxes to hide/show them.

Just looking for a way for the user to have control over what columns are hidden in a DT. My options would look like this: options=list(columnDefs = list(list(visible=FALSE, targets=columns2hide))), just need a way to fill columns2hide.

See: Hide certain columns in a responsive data table using DT package

lumiukko
  • 249
  • 3
  • 13
  • I found by adding ```extensions = 'Buttons',``` and ```dom = 'Bfrtip', buttons = list(list(extend = 'colvis', text='Column Picker', columns = c(1:19, 23:24)))``` to my DT, it creates a Button above my DT that allows me to show/hide specific columns. – lumiukko Aug 14 '20 at 12:21
  • Problem now is that I have some JS, ```tags$style(HTML(".table table tbody td:nth-child(n+23) {pointer-events: none;} .table table tbody td:nth-child(n+23)>div {pointer-events: auto;}"))``` that disables double-clicking cells to edit them (since some of my columns in my DT are editable) . The JS contains nth-child which changes when I hide columns and then refers to a different column. How can nth-child change dynamically? – lumiukko Aug 14 '20 at 12:21

0 Answers0