View source: R/rk.JS.optionset.R
rk.JS.optionset | R Documentation |
This function scans an object generated by rk.XML.optionset
,
extract IDs of all optioncolumn objects and nest the JavaScript code you define via ...
inside
a for loop that iterates through all columns. Inside ...
,
you can use the column objects of
rk.XML.optioncolumn
to refer to the respective column,
rk.JS.optionset
will use appropriate variables.
rk.JS.optionset( optionset, ..., loopvar = "i", collapse = ",\\n\\t", vars = FALSE, guess.getter = TRUE )
optionset |
A XiMpLe.node object, the full |
... |
The JavaScript code, optionally including the optioncolumn objects. This will become the body of the for loop. |
loopvar |
Character, name of the index variable used in the for loop. |
collapse |
Character string,
how all optioncolumns should be concatenated on the R code level
Hint: To place each one on a new line with tab indentation, set |
vars |
Logical,
if |
guess.getter |
Logical,
if |
In case you simply want to define the variables, but not run the loop yet,
set vars=TRUE
and
leave ...
empty.
rk.XML.optionset
,
rk.XML.optioncolumn
# this example is taken from the plugin skeleton script # first set up an optionset object dep.optionset.packages <- rk.XML.optionset( content=rk.XML.frame(rk.XML.stretch(before=list( rk.XML.row( dep.pckg.name <- rk.XML.input("Package"), dep.pckg.min <- rk.XML.input("min"), dep.pckg.max <- rk.XML.input("max"), dep.pckg.repo <- rk.XML.input("Repository") ) )), label="Depends on R packages"), optioncolumn=list( dep.optioncol.pckg.name <- rk.XML.optioncolumn(connect=dep.pckg.name, modifier="text"), dep.optioncol.pckg.min <- rk.XML.optioncolumn(connect=dep.pckg.min, modifier="text"), dep.optioncol.pckg.max <- rk.XML.optioncolumn(connect=dep.pckg.max, modifier="text"), dep.optioncol.pckg.repo <- rk.XML.optioncolumn(connect=dep.pckg.repo, modifier="text") ) ) # now translate it to JavaScript for loop JS.optionset <- rk.JS.optionset(dep.optionset.packages, echo("c("), echo("name=\"", dep.optioncol.pckg.name, "\""), ite(dep.optioncol.pckg.min, echo(", min=\"", dep.optioncol.pckg.min, "\"")), ite(dep.optioncol.pckg.max, echo(", max=\"", dep.optioncol.pckg.max, "\"")), ite(dep.optioncol.pckg.repo, echo(", repository=\"", dep.optioncol.pckg.repo, "\"")), echo(")") )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.