Class Table
Object
|
+--Widget
|
+--Container
|
+--Table
- class
Table
- extends Container
Raises:
selectionchanged
- whenever the selection changes. Listeners are passed an
AbstractList
of TableRow
s that are currently selected.
rowdoubleclicked
- whenever a row is double-clicked. Listeners are passed the
TableRow
that was double-clicked.
sortrequest
- whenever a column-header is clicked. Listeners are passed the index of the column-header that was clicked (the left-most column has index 0 and indexes increase to the right).
Defined in table.js
Constructor Summary |
Table
(<boolean> multiSelect, <boolean> disableSelection)
Creates a table.
|
Method Summary |
void
|
appendColumn(<TableColumn> column, <boolean> layout)
Appends a column to this table.
|
void
|
blur()
|
function
|
disableSelection(disable)
|
void
|
focus()
|
Pixels
|
getClientWidth()
|
int
|
getColumnCount()
Returns the column count for this table.
|
Object
|
getColumnWidth(<int> index)
Returns the width of column index .
|
AbstractList
|
getSelection()
|
void
|
handleClick(row, isShiftPressed, isCtrlPressed)
Updates the table's selection based on the current selection, the row
that was just clicked, the shift- and ctrl-states, whether or not
selection is allowed, and whether or not multi-selection is allowed.
|
void
|
prependColumn(<TableColumn> column, <boolean> layout)
Prepends a column to this table.
|
void
|
removeAllColumns()
|
void
|
removeColumn(<TableColumn> column, <boolean> layout)
Removes the given column.
|
void
|
setColumnWidth(<int> column, <float> width, <float> weight, <boolean> usePixels)
Sets the width of column column to width .
|
void
|
setDefaultRowHeight(<float> height, <boolean> canGrow, <boolean> usePixels)
Sets the default row height to height .
|
void
|
setSelection(<Object> selection)
Selects the rows indicated by selection .
|
void
|
setSortOrder(<int> column, <int> direction)
Updates the table's column headers to reflect the table being
sorted by column column in direction order.
|
Methods inherited from class Container |
appendChild, clear, contains, insertAfter, insertAt, insertBefore, isEmpty, prependChild, removeChild, replaceChild, setLayout, setEnabled
|
Methods inherited from class Widget |
installContextMenu, installDefaultContextMenu, uninstallContextMenu, isDraggable, setDraggable, addEventListener, createEventTable, dispose, getAbsoluteBottom, getAbsoluteLeft, getAbsoluteRight, getAbsoluteTop, getBottom, getBounds, getClientHeight, getCorner, getHeight, getLeft, getPixelsPerEm, getRight, getToolTip, getTop, getWidth, isDisposed, isEnabled, layout, moveToAbsolute, moveTo, raiseEvent, registerEventType, removeEventListener, setAbsoluteBottom, setAbsoluteLeft, setAbsoluteRight, setAbsoluteTop, setBottom, setBounds, setHeight, setLeft, setRight, setToolTip, setTop, setWidth, setParent, toString
|
_sortColumn
var _sortColumn
_sortOrder
var _sortOrder
children
var children
selection
var selection
SORT_ASCENDING
<static> var SORT_ASCENDING
SORT_DESCENDING
<static> var SORT_DESCENDING
SORT_NONE
<static> var SORT_NONE
Table
function Table(<boolean> multiSelect, <boolean> disableSelection)
Parameters:
multiSelect
- if true
then the user can select more than one row by holding a combination of Shift and Ctrl while clicking
disableSelection
- (Optional) - if true
then the user cannot change the table's selection. Defaults to false
.
appendColumn
void appendColumn(<TableColumn> column, <boolean> layout)
Appends a column to this table.
Parameters:
column
- the column to append.
layout
- (Optional) a boolean
indicating whether or not this table should be laid out after column
has been appended.
blur
void blur()
disableSelection
function disableSelection(disable)
focus
void focus()
getClientWidth
Pixels getClientWidth()
getColumnCount
int getColumnCount()
Returns the column count for this table.
Returns:
this table's column count
getColumnWidth
Object getColumnWidth(<int> index)
Returns the width of column index
.
Parameters:
index
- the column whose width you're interested in
Returns:
a structure describing the width of column index
getSelection
AbstractList getSelection()
handleClick
void handleClick(row, isShiftPressed, isCtrlPressed)
Updates the table's selection based on the current selection, the row
that was just clicked, the shift- and ctrl-states, whether or not
selection is allowed, and whether or not multi-selection is allowed.
If selection is not allowed, nothing is done. If multi-selection is not
allowed, then the table's selection is set to be {row}
. If
multi-selection is allowed, the following behaviour is expected:
ctrl
is true if the user is pressing the Ctrl
key
shift
is true if the user is pressing the Shift
key
base
is the current "base" of the selection.
base
is always the last row that was clicked while
the user was not pressing Shift
row
is the row that was clicked
selection
is the selection
min{a, b}
returns the argument with the lowest
index
max{a, b}
returns the argument with the highest
index
〈a, …, b〉
is an ordered set of
rows with a
having the lowest index and
b
having the higest
¬ctrl ∧ ¬shift ⇒ selection = 〈row〉 ∧ base = row
¬ctrl ∧ shift ⇒ selection = 〈min{row, base}, …, max{row, base}〉
ctrl ∧ ¬shift ∧ row ∈ selection ⇒ selection = selection - 〈row〉 ∧ base = row
ctrl ∧ shift ∧ base ∈ selection ⇒ selection = selection ∪ 〈min{row, base}, …, max{row, base}〉
ctrl &and ¬shift ∧ row ∉ selection ⇒ selection = selection ∪ 〈row〉 ∧ base = row
ctrl &and shift ∧ base ∉ selection ⇒ selection = (selection - 〈min{row, base}, …, max{row, base}〉) ∪ 〈row〉
prependColumn
void prependColumn(<TableColumn> column, <boolean> layout)
Prepends a column to this table.
Parameters:
column
- the column to prepend.
layout
- (Optional) a boolean
indicating whether or not this table should be laid out after column
has been prepended.
removeAllColumns
void removeAllColumns()
removeColumn
void removeColumn(<TableColumn> column, <boolean> layout)
Removes the given column. If layout
is true
then this.layout()
is called after the removal.
Parameters:
column
- the column to remove
layout
- a boolean
indicating whether or not this table should be laid out again after column
has been removed.
setColumnWidth
void setColumnWidth(<int> column, <float> width, <float> weight, <boolean> usePixels)
Sets the width of column column
to width
. To set the given
column back to the default settings, pass only column
. width
is
a number of ems unless usePixels
is true
. If weight
is zero then the given column will not grow (it will always be exactly width
units wide). If weight
is non-zero, then the given column will always be at
least width
units wide but will grow larger if there is extra space. The sum
of the column weights must be between zero and one.
Parameters:
column
- the index of column to affect
width
- the width of the column as a float
weight
- (Optional) - a number between zero and one indicating what portion of extra space should be allocated to this column. Defaults to zero.
usePixels
- (Optional) - a boolean
indicating whether width
is a number of ems or pixels. Defaults to false
.
setDefaultRowHeight
void setDefaultRowHeight(<float> height, <boolean> canGrow, <boolean> usePixels)
Sets the default row height to height
. If usePixels
is
true
then height
is interpreted as a pixel value, otherwise it is
interpreted as an em value. usePixels
defaults to
false
.
Parameters:
height
- the number of ems (or pixels, if usePixels
is true
) tall to make rows with unspecified height. height
is a float
and must be non-negative.
canGrow
- (Optional) - This parameter is not used. It exists for compatibility with FlexibleSizingFunction
usePixels
- (Optional) - a boolean
indicating whether to interpret height
as a number of pixels or a number of ems. height
is a number of pixels if and only if usePixels is true
.
setSelection
void setSelection(<Object> selection)
Selects the rows indicated by selection
.
selection
can be an AbstractList
of
TableRow
s, an array of TableRow
s, or
an individual TableRow
. If selection
is
null
, undefined
, or not provided, then the
table's selection is cleared.
Parameters:
selection
- an object describing which rows to select.
setSortOrder
void setSortOrder(<int> column, <int> direction)
Updates the table's column headers to reflect the table being
sorted by column column
in direction
order.
Doesn't actually sort the table in any way.
Parameters:
column
- the column by which this table is sorted
direction
- the direction in which the table is sorted. Must be one of Table.SORT_NONE
, Table.SORT_ASCENDING
, or Table.SORT_DESCENDING
.
