Considering the following simple Rshiny app,
ui <-shinyUI(fluidPage(
headerPanel("test"),
DT::dataTableOutput("tab"),
))
server <- function (input, output) {
output$tab <- DT::renderDataTable(
iris, extensions = 'Buttons', rownames = FALSE,
options = list(
dom = 'frtBip',
buttons = list('copy', list(extend = 'csv', filename= 'test'))
)
)
observeEvent(input$tab_rows_selected,{
})
}
shinyApp(ui=ui, server=server)
How can I ignore the headerPanel
entry so it is not considered for the copy
button? Ideally this means erasing the first two rows of information (I copied the output into a csv file for visualization purposes).
For the csv
button I managed (by coincidence) to achieve the task above by using rownames = FALSE
. Can anyone also please explain why that worked? I do not really follow the connection. Below I attach a screenshot of the output obtained by using the csv
button.
Try this:
buttons = list(
list(extend = 'copy', text = 'Copy', title = NULL),
list(extend = 'csv', filename= 'test')
)