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
})
}