# NOT RUN {
# Smart select input
if (interactive()) {
library(shiny)
library(shinyMobile)
shinyApp(
ui = f7Page(
title = "My app",
f7SingleLayout(
navbar = f7Navbar(title = "f7SmartSelect"),
f7SmartSelect(
inputId = "variable",
label = "Choose a variable:",
selected = "drat",
choices = colnames(mtcars)[-1],
openIn = "popup"
),
tableOutput("data")
)
),
server = function(input, output) {
output$data <- renderTable({
mtcars[, c("mpg", input$variable), drop = FALSE]
}, rownames = TRUE)
}
)
}
# Update smart select
if (interactive()) {
library(shiny)
library(shinyMobile)
shinyApp(
ui = f7Page(
title = "My app",
f7SingleLayout(
navbar = f7Navbar(title = "Update f7SmartSelect"),
f7Button("updateSmartSelect", "Update Smart Select"),
f7SmartSelect(
inputId = "variable",
label = "Choose a variable:",
selected = "drat",
choices = colnames(mtcars)[-1],
openIn = "popup"
),
tableOutput("data")
)
),
server = function(input, output, session) {
output$data <- renderTable({
mtcars[, c("mpg", input$variable), drop = FALSE]
}, rownames = TRUE)
observeEvent(input$updateSmartSelect, {
updateF7SmartSelect(
inputId = "variable",
openIn = "sheet",
selected = "hp",
choices = c("hp", "gear"),
multiple = TRUE,
maxLength = 3
)
})
}
)
}
# }
Run the code above in your browser using DataLab