Yahoo! UI Library

DataTable Widget  2.2.2

Yahoo! UI Library > datatable > DataTable

Class DataTable - uses YAHOO.util.EventProvider

DataTable class for the YUI DataTable widget.

Constructor

DataTable ( elContainer , oColumnSet , oDataSource , oConfigs )
Parameters:
elContainer <HTMLElement> Container element for the TABLE.
oColumnSet <YAHOO.widget.ColumnSet> ColumnSet instance.
oDataSource <YAHOO.util.DataSource> DataSource instance.
oConfigs <object> (optional) Object literal of configuration values.

Properties

_aSelectedRecords - private YAHOO.widget.Record[]

Array of Records that are in the selected state.

_bFocused - private Boolean

Internal variable to track whether widget has focus.

_elBody - private HTMLElement

TBODY element reference.

_elContainer - private HTMLElement

Container element reference. Is null unless the TABLE is built from scratch into the provided container.

_elFirstRow - private HTMLElement

First TR element reference pointer.

_elLastRow - private HTMLElement

Last TR element reference pointer.

_elTable - private HTMLElement

TABLE element reference.

_nCount - private static Number

Internal class variable to index multiple DataTable instances.

_nIndex - private Number

Instance index.

_oColumnSet - private YAHOO.widget.ColumnSet

ColumnSet instance.

_oRecordSet - private YAHOO.widget.RecordSet

RecordSet instance.

_paginator - private Object[]

Internal object literal to track built-in paginator values.

_paginator.currentPage - private Number

Tracks current page.

_paginator.dropdownOptions - private Number[] | Object[]

Internal variable to track paginator dropdown options.

_paginator.elements - private Object[]

Array of paginator UI references.

_paginator.elements.container - private HTMLElement

Reference to overall container element.

_paginator.elements.links - private HTMLElement

Reference to page links container element.

_paginator.elements.select - private HTMLElement

Reference to SELECT element.

_paginator.pageLinks - private Number

Internal variable to track paginator page links.

_paginator.rowsPerPage - private Number

Tracks rows per page.

_paginator.totalPages - private Number

Tracks total number of pages, calculated on the fly.

_selectRowAnchorId - private String

Id of anchor row for multiple selections.

_sName - private String

Unique instance name.

caption - String

Defines value of CAPTION attribute.

CLASS_BODY - static final String

Class name assigned to TBODY element that holds data rows.
Default Value: "yui-dt-body"

CLASS_CHECKBOX - static final String

Class name assigned to TD elements of type "checkbox".
Default Value: "yui-dt-checkbox"

CLASS_CURRENCY - static final String

Class name assigned to TD elements of type "currency".
Default Value: "yui-dt-currency"

CLASS_CURRENTPAGE - static final String

Class name assigned to pagination links for specific page numbers that are disabled.
Default Value: "yui-dt-currentpage"

CLASS_DATE - static final String

Class name assigned to TD elements of type "date".
Default Value: "yui-dt-date"

CLASS_EDITABLE - static final String

Class name assigned to editable TD elements.
Default Value: "yui-dt-editable"

CLASS_EDITOR - static final String

Class name assigned to editor DIV elements.
Default Value: "yui-dt-editor"

CLASS_EMAIL - static final String

Class name assigned to TD elements of type "email".
Default Value: "yui-dt-email"

CLASS_EMPTY - static final String

Class name assigned to empty elements.
Default Value: "yui-dt-empty"

CLASS_ERROR - static final String

Class name assigned to elements with error messaging.
Default Value: "yui-dt-error"

CLASS_EVEN - static final String

Class name assigned to even TR elements.
Default Value: "yui-dt-even"

CLASS_FIRST - static final String

Class name assigned to FIRST elements.
Default Value: "yui-dt-first"

CLASS_FIRSTLINK - static final String

Class name assigned to the pagination link "<<".
Default Value: "yui-dt-firstlink"

CLASS_FIRSTPAGE - static final String

Class name assigned to the pagination link "<<" when it is disabled.
Default Value: "yui-dt-firstpage"

CLASS_HEADCONTAINER - static final String

Class name assigned to container element within THEAD.

CLASS_HEADRESIZER - static final String

Class name assigned to resizer handle element within THEAD.
Default Value: "yui-dt-headresizer"

CLASS_HEADTEXT - static final String

Class name assigned to text displayed within THEAD.
Default Value: "yui-dt-headtext"

CLASS_HIGHLIGHT - static final String

Class name assigned to highlighted element.
Default Value: "yui-dt-highlight"

CLASS_LAST - static final String

Class name assigned to LAST elements.
Default Value: "yui-dt-last"

CLASS_LASTLINK - static final String

Class name assigned to the pagination link ">>".
Default Value: "yui-dt-lastlink"

CLASS_LASTPAGE - static final String

Class name assigned to the pagination link ">>" when it is disabled.
Default Value: "yui-dt-lastpage"

CLASS_LINK - static final String

Class name assigned to TD elements of type "link".
Default Value: "yui-dt-link"

CLASS_LOADING - static final String

Class name assigned to loading message.
Default Value: "yui-dt-loading"

CLASS_NEXTLINK - static final String

Class name assigned to the pagination link ">".
Default Value: "yui-dt-nextlink"

CLASS_NEXTPAGE - static final String

Class name assigned to the pagination link ">" when it is disabled.
Default Value: "yui-dt-nextpage"

CLASS_NUMBER - static final String

Class name assigned to TD elements of type "number".
Default Value: "yui-dt-number"

CLASS_ODD - static final String

Class name assigned to odd TR elements.
Default Value: "yui-dt-odd"

CLASS_PAGELINK - static final String

Class name assigned to pagination links to specific page numbers.
Default Value: "yui-dt-pagelink"

CLASS_PAGELINKS - static final String

Class name assigned to the pagination links container element.
Default Value: "yui-dt-pagelinks"

CLASS_PAGESELECT - static final String

Class name assigned to the pagination SELECT element.
Default Value: "yui-dt-pageselect"

CLASS_PAGINATOR - static final String

Class name assigned to the paginator container element.
Default Value: "yui-dt-paginator"

CLASS_PREVLINK - static final String

Class name assigned to the pagination link "<".
Default Value: "yui-dt-prevlink"

CLASS_PREVPAGE - static final String

Class name assigned to the pagination link "<" when it is disabled.
Default Value: "yui-dt-prevpage"

CLASS_SCROLLABLE - static final String

Class name assigned to container of a scrollable DataTable.
Default Value: "yui-dt-scrollable"

CLASS_SCROLLBODY - static final String

Class name assigned to scrolling TBODY element of a scrollable DataTable.
Default Value: "yui-dt-scrollbody"

CLASS_SELECTED - static final String

Class name assigned to selected elements.
Default Value: "yui-dt-selected"

CLASS_SORTABLE - static final String

Class name assigned to column headers of sortable Columns.
Default Value: "yui-dt-sortable"

CLASS_SORTEDBYASC - static final String

Class name assigned to column headers when sorted in ascending order.
Default Value: "yui-dt-sortedbyasc"

CLASS_SORTEDBYDESC - static final String

Class name assigned to column headers when sorted in descending order.
Default Value: "yui-dt-sortedbydesc"

CLASS_STRING - static final String

Class name assigned to TD elements of type "string".
Default Value: "yui-dt-string"

CLASS_TABLE - static final String

Class name assigned to TABLE element.
Default Value: "yui-dt"

contextMenu - YAHOO.widget.ContextMenu

ContextMenu instance.

dataSource - YAHOO.util.DataSource

DataSource instance.

fixedWidth - Boolean

True if DataTable's width is a fixed size.
Default Value: false

initialRequest - String

Initial request to send to DataSource.
Default Value: ""

isEmpty - object

Deprecated: No longer used.

MSG_EMPTY - static final String

Message to display if DataTable has no data.
Default Value: "No records found."

MSG_ERROR - static final String

Message to display while DataTable has data error.
Default Value: "Data error."

MSG_LOADING - static final String

Message to display while DataTable is loading data.
Default Value: "Loading data..."

pageCurrent - object

Deprecated: Deprecated in favor of paginatorOptions.currentPage

pageLinksLength - object

Deprecated: Deprecated in favor of paginatorOptions.pageLinks

pageLinksStart - object

Deprecated: No longer used.

pagers - object

Deprecated: Deprecated in favor of paginatorOptions.containers

paginator - Boolean

True if built-in paginator is enabled.
Default Value: false

paginatorOptions - Object

Object literal of initial paginator key:value properties.
Default Value: {}

paginatorOptions.containers - HTMLElement[]

Array of container elements to hold paginator UI, if enabled. If null, 2 containers will be created dynamically, one before and one after the TABLE element.
Default Value: null

paginatorOptions.currentPage - Number

If built-in paginator is enabled, current page to display.
Default Value: 1

paginatorOptions.dropdownOptions - Number[] | Object{}

Values to show in the SELECT dropdown. Can be an array of numbers to populate each OPTION's value and text with the same value, or an array of object literals of syntax {value:myValue, text:myText} will populate OPTION with corresponding value and text. A null value or empty array prevents the dropdown from displayed altogether.

paginatorOptions.pageLinks - Number

Maximum number of links to page numbers to show in paginator UI. Any pages not linked would be available through the next/previous style links. A 0 value displays all page links. A negative value disables all page links.
Default Value: 0

paginatorOptions.rowsPerPage - Number

If built-in paginator is enabled, each page will display up to the given number of rows per page. A value less than 1 will display all available rows.
Default Value: 500

rowSingleSelect - Boolean

True if only one row may be selected at a time.
Default Value: false

rowsPerPage - object

Deprecated: Deprecated in favor of paginatorOptions.rowsPerPage

rowsPerPageDropdown - object

Deprecated: Deprecated in favor of paginatorOptions.dropdownOptions

scrollable - Boolean

True if TBODY should scroll while THEAD remains fixed.
Default Value: false

sortedBy - Object

Object literal holds sort metadata: sortedBy.colKey sortedBy.dir

startRecordIndex - object

Deprecated: No longer used.

summary - String

Defines value of SUMMARY attribute.

Methods

_addRow

private String _addRow ( oRecord , index )
Add a new row to table body at position i if given, or to the bottom otherwise. Does not fire any events or apply any classes.
Parameters:
oRecord <YAHOO.widget.Record> Record instance.
index <Number> Position at which to add row.
Returns: String
ID of the added TR element.

_deleteRow

private void _deleteRow ( elRow )
Deletes a given row element as well its corresponding Record in the RecordSet. Does not fire any events.
Parameters:
elRow <element> HTML table row element reference.
Returns: void

_initHead

private void _initHead ( )
Populates THEAD element with TH cells as defined by ColumnSet.
Returns: void

_initHeadCell

private void _initHeadCell ( elHeadCell , oColumn , row , col )
Populates TH cell as defined by Column.
Parameters:
elHeadCell <HTMLElement> TH cell element reference.
oColumn <YAHOO.widget.Column> Column object.
row <number> Row index.
col <number> Column index.
Returns: void

_initPaginator

private void _initPaginator ( )
If pagination is enabled, initializes paginator container elements and sets internal tracking variables.
Returns: void

_initTable

private void _initTable ( )
Creates HTML markup for TABLE, THEAD, TBODY.
Returns: void

_onBlur

private void _onBlur ( e , oSelf )
Handles blur events on the TABLE element.
Parameters:
e <HTMLEvent> The blur event.
oSelf <YAHOO.widget.DataTable> DataTable instance.
Returns: void

_onClick

private void _onClick ( e , oSelf )
Handles click events on the TABLE element.
Parameters:
e <HTMLEvent> The click event.
oSelf <YAHOO.widget.DataTable> DataTable instance.
Returns: void

_onDocumentClick

private void _onDocumentClick ( e , oSelf )
Handles click events on the DOCUMENT. Hides active editor.
Parameters:
e <HTMLEvent> The click event.
oSelf <YAHOO.widget.DataTable> DataTable instance.
Returns: void

_onDocumentKeydown

private void _onDocumentKeydown ( e , oSelf )
Handles keydown events on the DOCUMENT. Executes interaction with editor.
Parameters:
e <HTMLEvent> The key event.
oSelf <YAHOO.widget.DataTable> DataTable instance.
Returns: void

_onDoubleclick

private void _onDoubleclick ( e , oSelf )
Handles doubleclick events on the TABLE element.
Parameters:
e <HTMLEvent> The doubleclick event.
oSelf <YAHOO.widget.DataTable> DataTable instance.
Returns: void

_onKeydown

private void _onKeydown ( e , oSelf )
Handles keydown events on the TABLE. Executes arrow selection.
Parameters:
e <HTMLEvent> The key event.
oSelf <YAHOO.widget.DataTable> DataTable instance.
Returns: void

_onKeypress

private void _onKeypress ( e , oSelf )
Handles keypress events on the TABLE. Mainly to support stopEvent on Mac.
Parameters:
e <HTMLEvent> The key event.
oSelf <YAHOO.widget.DataTable> DataTable instance.
Returns: void

_onKeyup

private void _onKeyup ( e , oSelf )
Handles keyup events on the TABLE. Executes deletion
Parameters:
e <HTMLEvent> The key event.
oSelf <YAHOO.widget.DataTable> DataTable instance.
Returns: void

_onMousedown

private void _onMousedown ( e , oSelf )
Handles mousedown events on the TABLE element.
Parameters:
e <HTMLEvent> The mousedown event.
oSelf <YAHOO.widget.DataTable> DataTable instance.
Returns: void

_onMouseout

private void _onMouseout ( e , oSelf )
Handles mouseout events on the TABLE element.
Parameters:
e <HTMLEvent> The mouseout event.
oSelf <YAHOO.widget.DataTable> DataTable instance.
Returns: void

_onMouseover

private void _onMouseover ( e , oSelf )
Handles mouseover events on the TABLE element.
Parameters:
e <HTMLEvent> The mouseover event.
oSelf <YAHOO.widget.DataTable> DataTable instance.
Returns: void

_onPagerClick

private void _onPagerClick ( e , oSelf )
Handles click events on paginator links.
Parameters:
e <HTMLEvent> The click event.
oSelf <YAHOO.widget.DataTable> DataTable instance.
Returns: void

_onPagerSelect

private void _onPagerSelect ( e , oSelf )
Handles change events on paginator SELECT.
Parameters:
e <HTMLEvent> The change event.
oSelf <YAHOO.widget.DataTable> DataTable instance.
Returns: void

_onRowDelete

private void _onRowDelete ( oArgs.rowIndexes )
Handles row delete events.
Parameters:
oArgs.rowIndexes <Number[]> The indexes of the deleted rows.
Returns: void

_resetFirstRow

private void _resetFirstRow ( )
Resets first row being tracked by class YAHOO.widget.DataTable.CLASS_FIRST.
Returns: void

_resetLastRow

private void _resetLastRow ( )
Resets last row being tracked by class YAHOO.widget.DataTable.CLASS_LAST.
Returns: void

_restripeRows

private void _restripeRows ( range )
Restripes rows by applying class YAHOO.widget.DataTable.CLASS_EVEN or YAHOO.widget.DataTable.CLASS_ODD.
Parameters:
range <Number> (optional) Range defines a subset of rows to restripe.
Returns: void

_select

private void _select ( els )
Sets elements to selected state. Does not fire any events. Does not affect internal tracker.
Parameters:
els <HTMLElement | String | HTMLElement[] | String[]> HTML element by reference or ID string, or array of HTML elements by reference or ID string.
Returns: void