I am looking for advice on how to structure my shiny flexdashboard app. I currently have a sidebar that contains a dateRangeInput()
and an actionButton()
. Once the action button is clicked a SQL query is run using the dates that were entered. I am trying to setup pickerInput()
filters in the sidebar to filter the resultant datatable and am unsure where I should be placing filtering. Currently within my observeEvent()
I am taking the input dates, running the sql, and using updatePickerInput()
to update the pickerInput()
values. Where should I be putting my reactive variable that then filters the df from the picker input?
My current structure looks like this:
-----Sidebar-----
dateRangeInput()
actionButton()
pickerInput()
-----Main Page-----
observeEvent(input$runquery, {
output$contents <- DT::renderDataTable (server=FALSE,{
#Pulling in date and running SQL
updatePickerInput()
filtered_data <-
reactive({
df %>%
filter(COL %in% input$col)
})
datatable(filtered_data(), class = 'cell-border stripe',
extensions = 'Buttons',
rownames = FALSE,
options = list(
pageLength=20,
autoWidth = TRUE,
dom = 'Bfrtip',
buttons = list(),
columnDefs = list(list(className = 'dt-center',width = '100px', targets = "_all"))),fillContainer=TRUE)
DT::dataTableOutput("contents")
})})
DT::dataTableOutput("contents")
This current structure loads the data and pickerInput()
values correctly however the filtering of the table with the pickerInput()
is not working. Should the reactive filtering be done outside of the observeEvent()
?