On my datatable I use the Buttons extension for the colVisGroup functions to hide or show selections of columns.
This works absolut fine and as I aspect.
The I read that one can give buttons an Input Value via
action=DT::JS("function ( e, dt, node, config ) { Shiny.setInputValue('colvis_Input', true, {priority: 'event'});}"
to let observeEvent
find them.
This also works absolut fine on my action buttons.
Now I want to combine these two and give every "Column Selection" an InputValue
, but I can't get it to work.
I noticed that the action
entry will "overwrite" the hide
and show
entries and when I assign an input value to a selection, it will not select these columns.
Is there a different way to assign the colvisGroup
with an InputValue
?
Is there a way to define the show
and hide
properties within the action
?
Example Code:
server = function(input, output){
colVis.button = list(list(extend="colvis",text="Columns",columns=1:11,
prefixButtons=list(list(extend="colvisGroup",text="Selection",show=c(1,2),hide=3:11),
list(extend="colvisGroup",text="Selection and Input value",
show=c(1,2),hide=3:11,
action=DT::JS("function ( e, dt, node, config ) {
Shiny.setInputValue('colvis_Input', true, {priority: 'event'});
}"
))) ) )
table = DT::renderDataTable(DT::datatable(mtcars,
extensions = c("Buttons"),
options=list(dom = "<t>B",buttons = colVis.button)))
output$table = table
shiny::observeEvent(input$colvis_Input, {
print("colvis_Input")
})
}
shiny::shinyApp(shiny::mainPanel(DT::dataTableOutput("table")),server)