I am trying to select only filtered rows using select all button that comes with select extension in shiny's DT package but it selects all the rows.
Here's the sample shiny app
Below is the reproducible code for the app:
library(DT)
data(mpg)
# Define UI for application
ui <- fluidPage(
# Application title
titlePanel("Select only filtered rows using selectall button"),
br(),
br(),
DT::dataTableOutput("table")
)
# Define server logic
server <- function(input, output) {
output$table <- DT::renderDataTable({
datatable(mpg, escape=F,
rownames=F,
filter = 'top',
# colnames = c("Data Type","Variable","Description", "Filename"),
class = "compact hover row-border",
extensions = c('Scroller','Select', 'Buttons'),
options = list(
select = list(style = "multi", items = "row"),
columnDefs = list(list(className = 'dt-center', targets = "_all")),
language = list(
info = 'Showing _START_ to _END_ of _TOTAL_ variables'),
deferRender = TRUE,
scrollY = 500,
scroller = TRUE,
dom = "Blfrtip",
buttons = c('selectAll', 'selectNone')
),
selection="none"
) }, server = F
)
}
# Run the application
shinyApp(ui = ui, server = server)
I think I may have to add some custom javascript to fix this but I am not good with it.
Can anyone help or give any suggestions.
Thanks