Class: ResultsTable

ResultsTable

The ResultsTable object, a displayable table with optional paging and sorting.

new ResultsTable(tag)

Parameters:
Name Type Description
tag String The ID string assigned to both id and name attributes of the table
Source:

Methods

addDiv(row, col, val, width)

Insert a span into a column of the table for later use (e.g., as a graphic element)
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 to create a unique ID
width string Optional width specifier
Source:

addHeader()

Adds a header to the table. Uses the anonymous argument array as input, so no declared args.
Source:

addHeaderStrings(sa)

Adds a header to the table. Uses an explicit array
Parameters:
Name Type Description
sa array Array of strings to be used as header items.
Source:

addRow()

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

addRowStrings(sa)

Adds a data row to the table. Used when you want to pass an existing array of strings.
Parameters:
Name Type Description
sa array Array of strings to be used as data items.
Source:
Example
myTable.addRow(myStringArray);

appendTo(parent)

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

enablePaging(listener)

Turn paging on for this object
Parameters:
Name Type Description
listener function An event listener to be called when user clicks on prev and next buttons
Source:

getCurrentPage() → {number}

Return the currently displayed page number.
Source:
Returns:
The current page number
Type
number

getDataValue(row, col) → {string}

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

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

getRowData(row) → {array}

Get the contents of one row
Parameters:
Name Type Description
row number The row of interest, zero being first tbody row
Source:
Returns:
The 'td' values in that row, or null if row does not exist
Type
array

getRows() → {number}

Get the number of rows in the table
Source:
Returns:
The row count
Type
number

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:

nextPage()

Display the next page of the table; called from event listener.
Source:

prevPage()

Display the previous page of the table; called from event listener.
Source:

setClass(clinfo)

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

setColumnClass(col, style)

Set the CSS class for a column
Parameters:
Name Type Description
col number The column of interest
style string The CSS class name
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 number The new value
Source:

setPageSize(sz)

Set the number of table rows per page
Parameters:
Name Type Description
sz number The number of rows per page
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