jstree-shiny | R Documentation |
Output and render functions for using jstree
within
Shiny applications and interactive Rmd documents. See examples with
jstreeExample
.
jstreeOutput(outputId, width = "100%", height = "auto")
renderJstree(expr, env = parent.frame(), quoted = FALSE)
outputId |
output variable to read from |
width , height |
must be a valid CSS unit (like |
expr |
an expression that generates a |
env |
the environment in which to evaluate |
quoted |
logical, whether |
jstreeOutput
returns an output element that can be included
in a Shiny UI definition, and renderJstree
returns a
shiny.render.function
object that can be included in a Shiny server
definition.
If the outputId
is called "ID"
for example, you have four
or seven available Shiny input
values in the server:
input[["ID"]]
contains the tree with the node fields text
and data
only, input[["ID_full"]]
contains the full tree,
input[["ID_selected"]]
contains the selected nodes,
input[["ID_selected_paths"]]
is like input[["ID_selected"]]
except that it provides the paths to the selected nodes instead of only
the values of their text field. This makes four Shiny values always
present. There are three additional Shiny values if you have set
checkboxes=TRUE
in the jstree
command:
input[["ID_checked"]]
contains the checked nodes,
input[["ID_checked_paths"]]
provides the paths to the checked
nodes. If you have set checkboxes=TRUE
and
checkWithText=TRUE
(the default), then these two additional
Shiny values are useless because 'checked' is the same as 'selected' in
this situation. Try jstreeExample("checkWithText")
. Finally, the
seventh Shiny value that is provided when checkboxes=TRUE
is
input[["ID_checked_tree"]]
. It is like input[["ID_checked"]]
except that it returns the hierarchy, in other words it provides the
checked nodes with their parent(s).
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.