Class: CheckboxTable

CheckboxTable

The CheckboxTable object, a displayable table with a checkbox column and optional sorting (no paging)

new CheckboxTable()

Source:

Methods

addDiv(row, col, val, width)

Insert a div into a cell of the table for later use (e.g., as a graphic element or control)
Parameters:
Name Type Description
row number The row of interest, zero being first tbody row
col number The column of interest
val string The name base of the span, to which we append the row number
width string Optional width specifier
Source:

addHeader((anonymous))

Adds a header to the table. Uses the anonymous arguments array as input, so no declared args.
Parameters:
Name Type Description
(anonymous) Array.<string> The columns headers for the table
Source:

addRow() → {integer}

Adds a data row to the table. Uses the anonymous arguments array as input, so no declared args.
Source:
Returns:
row index added.
Type
integer
Example
myTable.addRow('ken','707-555-1212','ken@calast.com');

addRowWithValue() → {integer}

Adds a data row to the table. Uses the anonymous arguments array as input, so no declared args. The first argument is not displayable, but is assigned to the checkbox as a value.
Source:
Returns:
row index added.
Type
integer
Example
myTable.addRowWithValue(42,'ken','707-555-1212','ken@calast.com');

appendTo(parent)

Appends the table (and page block) to a parent node
Parameters:
Name Type Description
parent Object The DOM element node to which this is added
Source:

clearBody()

Deletes all the data rows in a table by deleting children of tbody
Source:

deselectAll()

Sets all the rows in the table to unchecked
Source:

getDataClass(row, col) → {mixed}

Get the class of one table element for a specified row and column
Parameters:
Name Type Description
row number The row of interest, zero being the first tbody row
col number The column of interest
Source:
Returns:
The 'td' class at that row and column or null if not found
Type
mixed

getDataValue(row, col) → {mixed}

Get the contents of one table element for a specified row and column
Parameters:
Name Type Description
row number The row of interest, zero being the first tbody row
col number The column of interest
Source:
Returns:
The 'td' value at that row and column or null if not found
Type
mixed

getFontWeight(row) → {string}

Retrieves the font weight for one table row, as specified by its index.
Parameters:
Name Type Description
row number The row of interest, zero being the first tbody row
Source:
Returns:
weight The font weight for that row, or null if it does not exist
Type
string

getHeaderValue(row, col) → {mixed}

Get the contents of one table header element for a specified row and column
Parameters:
Name Type Description
row number The row of interest, zero being the first thead row
col number The column of interest
Source:
Returns:
The 'th' value at that row and column or null if not found
Type
mixed

getInnerText(el) → {String}

This function retrieves the text in a DOM-independent way
Parameters:
Name Type Description
el Object The DOM element whose text content is to be retrieved
Source:
Returns:
Text contents of the table cell
Type
String

getNextSelectedIndex() → {number}

This method returns the index of the next checked item, or null if there isn't one. A static index is maintained in the object, so we know which ones we have already seen. We start from just after that point to find the next one. Since a checkboxTable object may contain inputElements as column values, we look at the inputs in each row, and use the first input as the checkbox.
Source:
Returns:
The index of the next selected row, or null if there is no next selected row.
Type
number

getNextSelectedValue() → {mixed}

This method returns the value of the next checked item, or null if there isn't one
Source:
Returns:
The value of the button in the next selected row
Type
mixed

getRow() → {number}

Returns the currently selected row
Source:
Returns:
The current row variable
Type
number

getRowColor(row) → {string}

Retrieves the background color for one table row, as specified by its index.
Parameters:
Name Type Description
row number The row of interest, zero being the first tbody row
Source:
Returns:
color The background color for that row, or null if it does not exist
Type
string

getRowCount() → {number}

Returns the number of rows that have been added to the table
Source:
Returns:
The row count
Type
number

getSelectedCount() → {mixed}

This method returns the number of checked rows
Source:
Returns:
The count of checked rows
Type
mixed

getSelectedRow() → {number}

Get the index of the currently selected row. Counts the header, so first row is 1, not 0. For checkbox tables, this function disallows multiple select. It returns null if zero or more than one rows are selected.
Source:
Returns:
The row index, or null if no row is selected.
Type
number

getSelectedValue() → {mixed}

Get the value of the checkbox of the currently selected row. Requires use of addRowWithValue. For checkbox tables, this method disallows multiple select. It returns null if zero or more than one rows are selected.
Source:
Returns:
The value of the checkbox, or null if the number of selected rows is not one.
Type
mixed

getValueForIndex(row) → {mixed}

Get the value of the checkbox of a selected row. Requires use of addRowWithValue.
Parameters:
Name Type Description
row integer The row to be retrieved (0..n-1)
Source:
Returns:
The value of the checkbox, or null if row does not exist.
Type
mixed

hideUnselected()

Collapse a table to show only the selected rows. Does nothing if less than two rows.
Source:

isChecked(row) → {boolean}

Tests a specific table row to see if it is checked or unchecked
Parameters:
Name Type Description
row integer The row to be tested (0..n-1)
Source:
Returns:
The state of the checkbox, or false if bad row number
Type
boolean

makeSortable()

Make this table sortable - must be called after table has its contents Although most of the code for this method is original, many of the design ideas were inspired by examples at http://www.webtoolkit.info/, and much credit is due to the author(s) of that site.
Source:

resetIndex()

Sets the search index of the table to zero, so it can be re-searched.
Source:

selectAll()

Sets all the rows in the table to checked
Source:

setBold(row)

Set the text style for one table row, as specified by its index, to bold.
Parameters:
Name Type Description
row number The row of interest, zero being the first tbody row
Source:

setChecked(row, turnon)

Sets a specific table row to be checked or unchecked
Parameters:
Name Type Description
row integer The row to be affected (0..n-1)
turnon boolean Set to checked if true, unchecked otherwise
Source:

setClass(clinfo)

Assigns a CSS class to the table - the default class is CheckboxTable
Parameters:
Name Type Description
clinfo string The CSS class to assign to the table's class attribute
Source:

setDataValue(row, col, val)

Set the contents of one data element by specified row and column
Parameters:
Name Type Description
row number The row of interest, zero being first tbody row
col number The column of interest
val string The new value
Source:

setInputElement(row, col, val)

Replace the contents of specified row and column with an input element, and give the element the class inputElement in addition to any classes it already has.
Parameters:
Name Type Description
row number The row of interest, zero being first tbody row
col number The column of interest
val string The new value (an input element)
Source:

setRowClass(row, clinfo)

Apply a class to one table row, as specified by its index.
Parameters:
Name Type Description
row number The row of interest, zero being the first tbody row
clinfo string The new class for that row
Source:

setRowColor(row, color)

Set the background color for one table row, as specified by its index.
Parameters:
Name Type Description
row number The row of interest, zero being the first tbody row
color string The new background color for that row
Source:

sort(cell)

This function does the actual sort
Parameters:
Name Type Description
cell Object The DOM element that actually got clicked on
Source:

sortAlpha(a, b) → {Number}

This function does a sort compare of two alpha fields in a case-independent way
Parameters:
Name Type Description
a Object First DOM element
b Object Second DOM element
Source:
Returns:
0 if equal, 1 if a > b, -1 if a < b
Type
Number

sortNumeric(a, b) → {Number}

This function does a sort compare of two numeric fields
Parameters:
Name Type Description
a Object First DOM element
b Object Second DOM element
Source:
Returns:
0 if equal, 1 if a > b, -1 if a < b
Type
Number