r - Reset tableoutput with action button in shinydashboard -
i have shinydashboard app, app filter box , tabset show datatatable depending on filter. have reset button reset filters whith shinyjs::reset function, , want reset tableset , showing complete table or nothing. want valuboxes.
my app :
for server interface have basic : output$tableprint_a <- dt::renderdatarable ({})
ui :
body <- dashboardbody( tabitems( #### first tab item ##### tabitem(tabname = "fpc", fluidrow( infoboxoutput("kpm_inf", width = 6), infoboxoutput(outputid = "fpc_inf", width = 6) ), fluidrow( box(title = "variables filter", shinyjs::useshinyjs(), id = "side_panel", br(), background = "light-blue", solidheader = true, width = 2, selectinput("aaa", "aaa", multiple = t, choices = c("all", as.character(unique(fpc$aaa)))) br(), br(), p(class = "text-center", div(style = "display:inline-block", actionbutton("go_button", "search", icon = icon("arrow-circle-o-right"))), div(style = "display:inline-block", actionbutton("reset_button", "reset", icon = icon("repeat")))), p(class = 'text-center', downloadbutton('dl_fpc', 'download data'))), tabbox( title = taglist(), id = "tabset1", width = 10, tabpanel( "a \u2030 ", dt::datatableoutput("tableprint_a"), bsmodal(id = 'startupmodal', title = 'update message', trigger = '', size = 'large', tags$p(tags$h2("last update of : 01/09/2017", br(), br(), "last update of b : 01/09/2017", br(), br(), "last update of c : 01/09/2017", style = "color:green", align = "center"))) ), tabpanel( "b % table", dt::datatableoutput("tableprint_b")), type = "pills" ) ), fluidrow( # dynamic valueboxes valueboxoutput("info_gen", width = 6) )
i tried :
observeevent(input$reset_button, { output$tableprint_a <- null })
edit:
i want that, when action search button want appear again :
shinyjs::onclick("reset_button", shinyjs::toggle(id = "tableprint_a", anim = true))
you should try out:
output$tableprint_a <- renderdatatable({ if(input$reset_button == 1) { null }else{ datatable(...) } })
if button clicked nothing displayed, else datatable
shown.
[edit]
library(shiny) library(dt) shinyapp( ui = fluidpage(selectinput("select", "select", choices = unique(iris$species), multiple = t), actionbutton("go_button", "search", icon = icon("arrow-circle-o-right")), actionbutton("reset_button", "reset", icon = icon("repeat")), dt::datatableoutput('tbl')), server = function(input, output) { values <- reactivevalues(matrix = null) observe({ if (input$go_button == 0) return() values$matrix <- iris[iris$species %in% input$select, ] }) observe({ if (input$reset_button == 0) return() values$matrix <- null }) output$tbl = dt::renderdatatable({ datatable(values$matrix, options = list(lengthchange = false))} ) } )
Comments
Post a Comment