Class YAHOO.widget.RowExpansionDataTable
- extends YAHOO.widget.DataTable
The RowExpansionDataTable class extends the DataTable class to provide
functionality for expanding rows to show more contextual data.
Constructor
YAHOO.widget.RowExpansionDataTable
(
elContainer
,
aColumnDefs
,
oDataSource
,
oConfigs
)
- Parameters:
-
elContainer
<HTMLElement>
Container element for the TABLE.
-
aColumnDefs
<Object[]>
Array of object literal Column definitions.
-
oDataSource
<YAHOO.util.DataSource>
DataSource instance.
-
oConfigs
<object>
(optional) Object literal of configuration values.
Methods
private
void
_destroyExpansion
(
recordId
)
Destroys a expansion row
- Parameters:
-
recordId
<object>
DOM reference to a TR element (or child of a TR element), RecordSet position index, or Record ID.
- Returns:
void
private
void
_initEvents
(
)
Initialize internal event listeners
void
collapseAllRows
(
)
Collapses all expanded rows.
Boolean
collapseRow
(
recordId
)
Sets the expansion state of a row to collapsed
- Parameters:
-
recordId
<Mixed>
Record / Row / or Index id
- Returns:
Boolean
- successful
void
deleteRow
(
row
)
This is an override for DataTable's own deleteRow
to delete the expansion row before the main row is deleted
- Parameters:
-
row
<HTMLElement | String | Number>
DOM element reference or ID string
to DataTable page element or RecordSet index.
- Returns:
void
void
deleteRows
(
row
,
count
)
This is an override for DataTable's own deleteRows
to delete the expansion rows before the main rows are deleted
- Parameters:
-
row
<HTMLElement | String | Number>
DOM element reference or ID string
to DataTable page element or RecordSet index.
-
count
<Number>
(optional) How many rows to delete. A negative value
will delete towards the beginning.
- Returns:
void
void
destroy
(
)
Overrides DataTable's destroy method to also destroy expansion rows.
Boolean
expandRow
(
recordId
)
Sets the expansion state of a row to expanded
- Parameters:
-
recordId
<Mixed>
Record / Row / or Index id
- Returns:
Boolean
- successful
void
forAllRecords
(
fn
,
scope
)
Loops through all Record instances in the RecordSet
- Parameters:
-
fn
<Function>
Reference to a function that will be called once for ever record.
fn will receive a Record instance and the index for the record as its arguments.
fn may return false to break out of the loop.
-
scope
<Object>
(optional) Scope to execute fn in. It defaults to the DataTable instance.
- Returns:
void
HTMLElement
getExpansionContainer
(
recordId
)
returns the container element for the expansion
- Parameters:
-
recordId
<Mixed>
Record / Row / or Index id
- Returns:
HTMLElement
- container element
Object
getExpansionState
(
recordId
,
key
)
Gets expansion state object for a specific record associated with the
DataTable.
- Parameters:
-
recordId
<Mixed>
Record / Row / or Index id
-
key
<String>
(optional) Key to return within the state object. Default is to
return all as a map
- Returns:
Object
- State data object or value for Key.
The full state object contains
- record: reference to the associated Record instance
- expanded: true when the row is expanded
- expTrEl: the TR element for the expansion row
- expLinerEl: the container for the expansion
- other: Developers may store extra information in it
void
initAttributes
(
configuration
)
Over-ridden initAttributes method from DataTable, inherited from Element
- Parameters:
-
configuration
<Object>
attributes taken from the fourth argument to the constructor
- Returns:
void
void
initializeTable
(
)
This is an override for DataTable's own initializeTable
which it calls after it destroys all expansion rows
void
onDataReturnSetRows
(
)
This is an override for DataTable's own onDataReturnSetRows
which it calls after it destroys all expansion rows since
with server-side pagination, with every new page it ignores the previous records
void
onEventToggleRowExpansion
(
oArgs
)
Helper method which toggles row expansion.
- Parameters:
-
oArgs
<Object>
context of a subscribed event
- Returns:
void
void
restoreExpandedRows
(
)
Restores rows which have been expanded state but the original markup
has been removed from the page.
Object
setExpansionState
(
recordId
,
key
,
value
)
Sets a value to a expansion state object with a given Key for a record
which is associated with the DataTable
- Parameters:
-
recordId
<Mixed>
Record / Row / or Index id
-
key
<String>
Key to use in map
-
value
<Mixed>
Value to assign to the key
- Returns:
Object
- State data object
void
toggleRowExpansion
(
recordId
)
Toggles the expansion state of a row
- Parameters:
-
recordId
<Mixed>
Record / Row / or Index id
- Returns:
void
Events
beforeRowExpansionTemplateChange
(
event
)
Fires before the value for the configuration attribute 'rowExpansionTemplate' changes. Return false to cancel the attribute change.
- Parameters:
-
event
<{oldValue: any, newValue: any}>
An object containing the previous attribute value and the new value.
rowCollapsedEvent
(
state
)
Fires when a row is collapsed
rowExpandedEvent
(
state
)
Fires when a row is expanded
rowExpansionDestroyEvent
(
state
)
Fires when a row is about to be deleted
rowExpansionTemplateChange
(
event
)
Fires when the value for the configuration attribute 'rowExpansionTemplate' changes.
- Parameters:
-
event
<{oldValue: any, newValue: any}>
An object containing the previous attribute value and the new value.
Configuration Attributes
Template for the expansion row.
If a String, it will be processed through YAHOO.lang.substitute and will have all the values
in the associated Record available.
If a Function, it will receive the expansion state object, see:
getExpansionState
Default Value: null