Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

161
Vistas
Using both Select extension and server-side selection of rows in shiny app with datatable

I've been working on some R shiny app that allows users to browse some data. It is displayed in a table and I want this table to have two functionalities:

  • It should allow user to select rows from the table manually by clicking and using buttons to select all and deselect all.
  • It should allow user to select rows from the table by using some queries (not filtering it! -- unselected rows should still be displayed).

These functionalities are supposed to work simultaneously -- e.g. user may query the table by providing some conditions, select all rows fulfilling them by using some button and then add more rows to the selection by clicking them manually.

The first functionality can be easily obtained using Select extension for DT -- and it works perfectly well.

The second functionality can be implemented by taking some input from the user and selecting appropriate rows by using dataTableProxy objects and selectRows function on the server side -- and it works perfectly well.

The problem arises when I try combining them. I know that it is not advisable, console displays warnings when mixing them, but it just seemed the fastest solution for me.

Here is some simplified code:

library(shiny)
library(DT)

ui <- fluidPage(
  dataTableOutput("my_table"),
  actionButton("my_button", "Select some rows")
)


server <- function(input, output, session) {
  data(iris)
  
  output[["my_table"]] <- renderDataTable(
    iris,
#    extensions = c("Select", "Buttons"),
#    options = list(
#      dom = 'Brtip',
#      buttons = c("selectAll", "selectNone"),
##      select = list(style = "multi+shift", items = "row")
#    ),
#    server = FALSE,
##    selection = "none"
  )
  
  proxy <- dataTableProxy("my_table")
  
  observeEvent(input[["my_button"]], {
    proxy %>% selectRows(1:5)
  })
}

shinyApp(ui, server)

Lines that are commented out turn on selection buttons and replace default built-in selection for DT with selection API implemented in Select extension -- as a result making proxy selection on server side impossible. I can leave those double-commented lines commented and it seems to work, but only at a glance. In reality default selection of shiny "loses" with extension selection, which can be proven by the fact that even though some rows are displayed as selected, "Deselect all" button is inactive.

My question is: what is the easiest way to combine those two approaches? Is there any option for "Select" extension I am missing that would enable selection by shiny proxy? I could solve it by manually implementing some callbacks for table instead of using proxy, but it seems like a lot of work and I would be grateful for any suggestion how to avoid it.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda