Class Index | File Index

Classes


Class Alfresco.util.DataTable

Alfresco.util.DataTable is a helper class for easily creating a YUI DataTable with the following (optionally) added
functionality that uses a lot of default values to to minimize configuration:

- DataTable
* Sets default alfresco empty, loading and error messages
* Auto sets the width for columns that has width set in columnDefinition
* (Sorting support is not yet implemented)
- Paginator with:
* Uses Alfresco default pagination templates
* Urls created with default alfresco paging parameters
* PayLoad parsing form the response
- Browser History Manager
* Creates hidden element (and iframe for IE) automatically
* Loads state form url and fires from "filter" state and uses "paging" state to create paginated datasource url
- Filters
- Listens for "changeFilter" events, puts them as browser history state and reloads datatable when the state has changed
- Asks callback (dataSource.filterResolver) for url parameters that represent the current filter to create the datasource url

To see an example of a DataTable:
- with filters, pagination and browser history state is created, visit task-list.js
- without filters and browser history state BUT with a paginator only displaying the no of results, visit my-tasks.js

Note!
- ALL usual YUI DataTable, DataSource & Paginator constructor arguments may be provided to override the default ones set by YUI and this component.
- If a WebScript REST API call doesn't use skipCount & maxItems in its urls:
* Pass in a url resolver function to "dataSource.pagingResolver"
* Inform the paginator how the payload shall be parsed by setting values in "dataSource.config.responseSchema.metaFields"
* Note that only "index based" pagination is supported currently not "page based".
- If no paginator shall be created, simply omit it.
- If you want to instruct the datatable to load something without pagination use load(url)
Defined in: alfresco.js
Field Summary
Field Attributes Field Name and Description
 
The config passed in to the constructor
 
The current sort direction
 
The current filter
 
The current number of maximum values to display
 
The current number of items to skip
 
The current sort column/key
 
Place to save all data table formatters so we can call them later
 
Name space to save all yui widgets in
Method Summary
Method Attributes Method Name and Description
 
The default function to create the url parameters to apend to the datasource url.
 
findDataByParameter(p_parameter, p_value)
Searches the current recordSet for a record with the given parameter value
 
findRecordByParameter(p_parameter, p_value)
Searches the current recordSet for a record with the given parameter value
 
getData(oRecord)
Returns the data associated to the row.
 
Returns the DataTable instance
 
Returns the current filter values encoded as a browser history bookmark state string.
 
getPagingState(skipCount, maxItems)
Returns the current paging values encoded as a browser history bookmark state string.
 
getRecord(oRecord)
Returns a DataTable record by ID or RecordSet position.
 
loadDataTable(parameters)
Loads the datatable
 
Reloads the datatable with the current filter & pagination
 
setFilterState(filterState)
Takes a browser history bookmark state string and decodes it to set the current filter values.
 
setPagingState(pagingState)
Takes a browser history bookmark state string and decodes it to set the current paging values.
Field Detail
{Object} config
The config passed in to the constructor

{String} currentDir
The current sort direction

{Object} currentFilter
The current filter

{int} currentMaxItems
The current number of maximum values to display

{int} currentSkipCount
The current number of items to skip

{String} currentSortKey
The current sort column/key

{Object} formatters
Place to save all data table formatters so we can call them later

{Object} widgets
Name space to save all yui widgets in
Method Detail
createUrlParameters()
The default function to create the url parameters to apend to the datasource url.
Will call the "pagingResolver" if a paginator is present and a "filterResolver" if the funciton is present
and merge the returned urls. Override this method if the url that shall be added is so dynamic that its format
depends on more than the filter and pagination parameters.

findDataByParameter(p_parameter, p_value)
Searches the current recordSet for a record with the given parameter value
Parameters:
{string} p_parameter
Parameter to look for the value in
{string} p_value
Value to find
Returns:
The data asscoiated to the row.

findRecordByParameter(p_parameter, p_value)
Searches the current recordSet for a record with the given parameter value
Parameters:
{string} p_parameter
Parameter to look for the value in
{string} p_value
Value to find
Returns:
The data asscoiated to the row.

getData(oRecord)
Returns the data associated to the row.
Parameters:
oRecord
{HTMLElement|Number|String} DOM reference to a TR element (or child of a TR element), RecordSet position index, or Record ID.
Returns:
The data asscoiated to the row.

getDataTable()
Returns the DataTable instance
Returns:
The YUI DataTable instance.

getFilterState(filter)
Returns the current filter values encoded as a browser history bookmark state string.
Parameters:
filter

getPagingState(skipCount, maxItems)
Returns the current paging values encoded as a browser history bookmark state string.
Parameters:
skipCount
maxItems

{YAHOO.widget.Record} getRecord(oRecord)
Returns a DataTable record by ID or RecordSet position.
Parameters:
oRecord
{HTMLElement|Number|String} DOM reference to a TR element (or child of a TR element), RecordSet position index, or Record ID.
Returns:
{YAHOO.widget.Record} Record object

loadDataTable(parameters)
Loads the datatable
Parameters:
{String} parameters
(Optional) The url parameters to add to the datasource url

reloadDataTable()
Reloads the datatable with the current filter & pagination

setFilterState(filterState)
Takes a browser history bookmark state string and decodes it to set the current filter values.
Parameters:
filterState

setPagingState(pagingState)
Takes a browser history bookmark state string and decodes it to set the current paging values.
Parameters:
pagingState

Documentation generated by JsDoc Toolkit 2.4.0 on Thu Feb 16 2012 12:24:28 GMT-0000 (GMT)