searchTreeview: Search a 'treeviewInput'

Description Usage Arguments Value Examples

View source: R/server-treeview.R

Description

Search a treeviewInput

Usage

1
2
3
4
5
6
7
8
9
searchTreeview(
  inputId,
  pattern,
  ignore_case = TRUE,
  exact_match = FALSE,
  reveal_results = TRUE,
  collapse_before = TRUE,
  session = shiny::getDefaultReactiveDomain()
)

Arguments

inputId

The id of the input object.

pattern

Pattern to search for.

ignore_case

Case insensitive.

exact_match

Like or equals.

reveal_results

Reveal matching nodes.

collapse_before

Collapse all nodes before revealing results.

session

The session object passed to function given to shinyServer.

Value

None.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
library(shiny)
library(shinytreeview)

data("countries")

ui <- fluidPage(
  tags$h3("treeviewInput search example"),
  fluidRow(
    column(
      width = 4,
      treeviewInput(
        inputId = "country",
        label = "Choose a country:",
        choices = make_tree(
          countries, c("continent", "subregion", "name")
        ),
        width = "100%"
      )
    ),
    column(
      width = 8,
      textInput("search", "Search a country"),
      tags$b("Selected country:"),
      verbatimTextOutput(outputId = "result")
    )
  )
)

server <- function(input, output, session) {
  output$result <- renderPrint({
    input$country
  })

  observeEvent(input$search, {
    searchTreeview(
      inputId = "country",
      pattern = input$search,
      reveal_results = TRUE
    )
  })
}

if (interactive())
  shinyApp(ui, server)

zehndert/shinytreeviewCustom documentation built on Dec. 23, 2021, 9:15 p.m.