itemList: An itemList is used to store a list of similar items or...

Description Usage Arguments Value Note Examples

View source: R/itemlist.R

Description

An itemList is used to store a list of similar items or itemgroups with a means to edit individually

Usage

1
2
3
itemList(items = list(), items_name = "", item_factory = NULL, name,
  label = name, help = "", tooltip = "", attr = list(), model, editor,
  ...)

Arguments

items

list of similar items, may be empty list

items_name

Header name on top of table displaying item list

item_factory

function to call to produce a new item, e.g. function(.) numericItem(1)

name

name of itemList object

label

label for itemList object

help

help string

tooltip

tooltip

attr

attributes passed to make_ui constructor

model

optional model to pass in

editor

optional editor to pass in

...

passed along to Item\$proto() call

Value

A proto object. Call obj\$show_help() to view its methods and properties.

Note

This item's model is a a list storing child items or item groups. To create new items, the item_factory method should be provided. It provides a template for a new item, the editor allows the user to modify its values When a child item is edited the "done" button is clicked to close. The method post_process is called. (The edited changes may already have been sent back to the model.) The child items to_string method is called to make the label in the table that allows the user to select the child item to edit. This should be a character vector of length 1. The table can display an icon. Simply set the icon property of the icon to a gWidgets stock icon name.

The child items can be returned via the get_value method or the get_NAME method, where NAME is that passed into the name argument of the constructor. The to_R method can be modified to manipulate the return value. The vignette has an example where the output is coerced into a data frame. The default is a list with each child items to_R method called to form the numbered components.

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
## Not run: 
## make icons
imagedir <- system.file("images",package="traitr")
addStockIcons(gsub("\\\\.png","", list.files(path=imagedir)),
              list.files(path=imagedir, full.names=TRUE))
## make item
item <- itemList(items=list(),
                 items_name="Personnel",
                 item_factory = function(.) {
                   a <- anItemGroup(items=list(
                                      name=stringItem(""),
                                      rank=choiceItem("Scout",
                                           values=c("Scout","Captain","General")),
                                      serial.number = stringItem("", label="Serial number")))
                   a$post_process <- function(.) {
                    .$icon <- tolower(.$get_rank())
                    }
                   a$to_string <- function(., drop=TRUE) .$to_R()$name
                   return(a)
                 },
                 name="itemlist")

item$make_ui(container=gwindow("itemList test"))

## End(Not run)

traitr documentation built on May 2, 2019, 3:32 p.m.