Learn R Programming

shinysky (version 0.1.3)

textInput.typeahead: textinput.typeahead

Description

A simple typeahead text input component

Update textInput.typeahead

Usage

textInput.typeahead(id, placeholder, local, valueKey, tokens, template,
  limit = 20)

updateTextInput.typeahead(session, id, dataset, valueKey, tokens, template, limit = 20, placeholder = "")

Arguments

id

The id of the field

placeholder

The placeholder text. It is shown in the text input before any input has occurred

local

A data.frame containing all the information you want to make available to typeahead to display in the dropdown. You can use any of the variable in the dataset via the template argument

valueKey

The element that acts as the value key in the dataset usually an unique identifier of the row

tokens

A list whose length equal to nrow(local) where each element is array of string tokens. Typing the tokens will select the corresponding rows

template

A hogan template on how to show the content e.g. '<p> name </p>' where name is one of the variables in local

limit

An integer of the upper limit on how many hits to show in the typeahead dropdown

session

The Shiny session specified in shinyServer(function(input, output, session) ...).

dataset

The data.frame to render

See Also

Other ShinySky elements: actionButton, select2Input, shinyalert

Examples

Run this code
# NOT RUN {
# ui.R
textInput.typeahead(
id="thti"
,placeholder="type 'name' or '2'"
,local=data.frame(name=c("name1","name2"),info=c("info1","info2"))
,valueKey = "name"
,tokens=c(1,2)
,template = HTML("<p class='repo-language'>{{info}}</p> 
<p class='repo-name'>{{name}}</p> 
<p class='repo-description'>You need to learn more CSS to customize this further</p>")
)

# run the below and go to the typeahead tab
if(interactive()) {
  shinysky::run.shinysky.example()
}


# }

Run the code above in your browser using DataLab