A constructor for displaying tabular data for selection
The tabular widget allows a user to select one (or more) row(s)
using the mouse or keyboard selection. The selected rows are the
main property and are returned by svalue through their key (from
the column specified by chosen.col
), or by index. The
change handler changes on double-click event. Use add handler
click to respond to a change in selection.
.gtable generic for toolkit dispatch
For gtable one can pass in row(s) to select by index (when index=TRUE) or by match among the values in the chosen column. For setting by index, a value of 0L or integer(0) will clear the current selection
For GTable
objects the [
and [<-
methods are
(mostly) implemented. The [
method allows one to access the
object using the regular matrix notation (but there is no list
notation, e.g. $
or [[
, defined). The [<-
method is available, but for most toolkits is restricted: one can
not add columns, add rows, remove columns, remove rows, or change
the type of the column. For all of these actions, one can reassign
the items being displayed through the idiom obj[] <-
new_items
. This allows the widget to resize or redo the column
renderers.
The change handler for GTable
is called when the selection
changes. This is often the result of a click event (but need not
be), although we alias to addHandlerClicked
. For double
click events, see addHandlerDoubleclick
.
Double clicking is used to activate an item (single click is selection). We also bind pressing the Return key on an item to initiate this signal
For GTable
, visibility refers to which rows are currently
shown, not whether the widget itself is shown or hidden. (For the
latter, place the widget into a container and adjust that). One
can use this method to perform filtering by adjusting which rows
are displayed according to some criteria that returns a logical.
For GTable
the size<-
method is overridden to allow
one to specify the column widths. To do so, pass in the values for
width
, height
or column.widths
as named components
of a list. The value of column.widths
should be a numeric
vector of pixel widths of length matching the number of columns.
gtable(items, multiple = FALSE, chosen.col = 1, icon.col = NULL, tooltip.col = NULL, handler = NULL, action = NULL, container = NULL, ..., toolkit = guiToolkit()) .gtable(toolkit, items, multiple = FALSE, chosen.col = 1, icon.col = NULL, tooltip.col = NULL, handler = NULL, action = NULL, container = NULL, ...) ## S3 method for class 'GTable' svalue(obj, index = NULL, ..., value) ## S3 method for class 'GTable' x[i, j, ..., drop = TRUE] ## S3 method for class 'GTable' addHandlerChanged(obj, handler, action = NULL, ...) ## S3 method for class 'GTable' addHandlerDoubleclick(obj, handler, action = NULL, ...) ## S3 method for class 'GTable' visible(obj, ...) ## S3 replacement method for class 'GTable' size(obj) <- value
items |
data.frame specifies items for selection. May be a vector, matrix or data frame |
multiple |
logical allow multiple selection |
chosen.col |
which value from the row is returned by selection |
icon.col |
NULL or integer. If latter, specifies column containing stock icon |
tooltip.col |
NULL or integer. If latter, specifies column containing tooltip |
handler |
A handler assigned to the default change
signal. Handlers are called when some event triggers a widget to
emit a signal. For each widget some default signal is assumed, and
handlers may be assigned to that through Handlers may also be added via |
action |
User supplied data passed to the handler when it is called |
container |
A parent container. When a widget is created it can be incorporated into the widget heirarchy by passing in a parent container at construction time. (For some toolkits this is not optional, e.g. gWidgets2tcltk or gWidgets2WWW2.) |
... |
These values are passed to the |
toolkit |
Each widget constructor is passed in the toolkit it
will use. This is typically done using the default, which will
lookup the toolkit through |
obj |
object of method call |
index |
NULL or logical. If |
value |
value to assign for selection or property |
x |
|
i |
row index |
j |
column index |
drop |
do we drop when subsetting |
Many generic methods for data frames are implemented for
gtable
. These include [
, [<-
, length
,
names
, and names<-
Returns an object of class GTable
## Not run: w <- gwindow("gtable example", visible=FALSE) g <- gvbox(cont=w) tbl <- gtable(mtcars, cont=g, expand=TRUE, fill=TRUE) addHandlerClicked(tbl, handler=function(h,...) sprintf("You selected %s", svalue(h$obj))) visible(w) <- TRUE ## End(Not run)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.