-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
selectizeGroupServer() accept reactive data and vars
- Loading branch information
Showing
9 changed files
with
430 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,4 @@ | |
^data-raw$ | ||
^revdep$ | ||
^codecov\.yml$ | ||
^examples$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Default ----------------------------------------------------------------- | ||
|
||
if (interactive()) { | ||
|
||
library(shiny) | ||
library(shinyWidgets) | ||
|
||
data("mpg", package = "ggplot2") | ||
|
||
ui <- fluidPage( | ||
fluidRow( | ||
column( | ||
width = 10, offset = 1, | ||
tags$h3("Filter data with selectize group"), | ||
panel( | ||
selectizeGroupUI( | ||
id = "my-filters", | ||
params = list( | ||
manufacturer = list(inputId = "manufacturer", title = "Manufacturer:"), | ||
model = list(inputId = "model", title = "Model:"), | ||
trans = list(inputId = "trans", title = "Trans:"), | ||
class = list(inputId = "class", title = "Class:") | ||
) | ||
), status = "primary" | ||
), | ||
DT::dataTableOutput(outputId = "table") | ||
) | ||
) | ||
) | ||
|
||
server <- function(input, output, session) { | ||
res_mod <- callModule( | ||
module = selectizeGroupServer, | ||
id = "my-filters", | ||
data = mpg, | ||
vars = c("manufacturer", "model", "trans", "class") | ||
) | ||
output$table <- DT::renderDataTable(res_mod()) | ||
} | ||
|
||
shinyApp(ui, server) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
|
||
# Subset data ------------------------------------------------------------- | ||
|
||
if (interactive()) { | ||
|
||
library(shiny) | ||
library(shinyWidgets) | ||
|
||
data("mpg", package = "ggplot2") | ||
|
||
ui <- fluidPage( | ||
fluidRow( | ||
column( | ||
width = 10, offset = 1, | ||
tags$h3("Filter data with selectize group"), | ||
panel( | ||
pickerInput( | ||
inputId = "car_select", | ||
choices = unique(mpg$manufacturer), | ||
options = list( | ||
`live-search` = TRUE, | ||
title = "None selected" | ||
) | ||
), | ||
selectizeGroupUI( | ||
id = "my-filters", | ||
params = list( | ||
manufacturer = list(inputId = "manufacturer", title = "Manufacturer:"), | ||
model = list(inputId = "model", title = "Model:"), | ||
trans = list(inputId = "trans", title = "Trans:"), | ||
class = list(inputId = "class", title = "Class:") | ||
) | ||
), | ||
status = "primary" | ||
), | ||
DT::dataTableOutput(outputId = "table") | ||
) | ||
) | ||
) | ||
|
||
server <- function(input, output, session) { | ||
|
||
mpg_filter <- reactive({ | ||
subset(mpg, manufacturer %in% input$car_select) | ||
}) | ||
|
||
res_mod <- callModule( | ||
module = selectizeGroupServer, | ||
id = "my-filters", | ||
data = mpg_filter, | ||
vars = c("manufacturer", "model", "trans", "class") | ||
) | ||
|
||
output$table <- DT::renderDataTable({ | ||
req(res_mod()) | ||
res_mod() | ||
}) | ||
} | ||
|
||
shinyApp(ui, server) | ||
} |
Oops, something went wrong.