checkboxinput on DT / R Shiny

Hello all,

I try to add checkboxinput on my DT, on R shiny,

but when I push the checkbox, i do not see any change:



function(input, output,session) {

shinyInput = function(FUN, len, id, ...) {
    inputs = character(len)
    for (i in seq_len(len)) {
      inputs[i] = as.character(FUN(paste0(id, i), label = NULL, ...))
    }
    
    inputs
  }
  
  shinyValue = function(id, len) {
    unlist(lapply(seq_len(len), function(i) {
      value = input[[paste0(id, i)]]
      if (is.null(value)) NA else value
    }))
  }
  
  output$dt_PrixExt <- DT::renderDataTable({
    if(is.null(DataIntExtFilter()))return(NULL)
    if(dim(DataIntExtFilter())[1]==0)return(NULL)

    data<-DataIntExtFilter()

    remove = shinyInput(checkboxInput, dim(data)[1], 'remove_', value = FALSE)
    print(remove)

    data<-data.frame(remove,data)
    
    DT::datatable(data,extensions = 'Buttons',filter = 'top',
                  options = list(pageLength = 50, autoWidth = F, scrollX = T,paging = T, searching = T,
                                 dom = 'Bfrtip',
                                 buttons = c('copy', 'csv', 'excel', 'pdf', 'print'),
                                 preDrawCallback = JS('function() { Shiny.unbindAll(this.api().table().node()); }'),
                                 drawCallback = JS('function() { Shiny.bindAll(this.api().table().node()); } ')
                  ),
                  escape = FALSE
    )

  })
  
  DataRemove <- eventReactive(input$GoDelete,{
    
    data<-DataIntExtFilter()
    
    df<-data.frame(data$reference.annonce,remove = shinyValue('remove_', dim(data)[1]))
    names(df)<-c("ref","remove")
    df<-df[!is.na(df$remove),]
    df<-df[df$remove==TRUE,]
    df<-df[!duplicated(df$ref),]
    
    print(df)

  df
    
  })
  
  output$text_rem <- renderText({
    
    if(is.null(DataRemove()))return(NULL)
    
    data<-DataIntExtFilter()
    df<-data.frame(data$reference.annonce,remove = shinyValue('remove_', dim(data)[1]))
    names(df)<-c("ref","remove")
    df<-df[!is.na(df$remove),]
    df<-df[df$remove==TRUE,]
    df<-df[!duplicated(df$ref),]
    
    text<-"- Suppresion annonce(s): "
    x<-paste(df$ref,collapse = ",")
    text<-paste(text,x,sep="")
    text
    
  })

}

Hi,

in order for us to help you with your question, please provide us a minimal reproducible example (Reprex) where you provide a minimal (dummy) dataset and code that can recreate the issue. One we have that, we can go from there. For help on creating a Reprex, see this guide:

1 Like

the app code is very long,

the idea is:

  • I have DT on shiny, with filter (outside of DT)
  • I plug the checkboxinput
  • when I put a filter, the checkbox doesn't work

thx
David

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.