DataTable
Provides a Widget that is responsible for rendering columnar data into a highly customizable and fully accessible HTML table. The core functionality of DataTable is to visualize structured data as a table. A variety of Plugins can then be used to add features to the table such as sorting and scrolling.
As of 3.5.0, the architecture and APIs have changed to the following architecture:
Class composition
Y.DataTable.Core- Class extension
- APIs and ATTRS for extending Widget
- Responsible for rendering the
<table>,<caption>, and empty<thead>,<tfoot>, and<tbody>as appropriate
Y.DataTable.Base- Widget generated from
Y.Base.create('datatable', Y.Widget, [Core]) - Featureless DataTable constructor
- Defaults
headerViewtoY.DataTable.HeaderViewandbodyViewtoY.DataTable.BodyView
- Widget generated from
Y.DataTableY.DataTable.BaseSubclass- Constructor with all
use()d features - Namespace for DT-specific extensions and component classes
Y.DataTable.HeaderViewY.Viewsubclass- Renders the content of the
<thead>
Y.DataTable.BodyViewY.Viewsubclass- Renders the content of the
<tbody>
Y.DataTable.ColumnWidths- Class extension
- Renders
<colgroup>and<col>s - Supports
widthconfiguration in column defs - Adds
setColumnWidth()method - Automatically mixed onto
Y.DataTable
Y.DataTable.Mutable- Class extension
- Adds
addRow(),addRows(),addColumn(),modifyColumn(), etc - Automatically mixed onto
Y.DataTable
Events
Is a bubble target for it’s ModelList and all configured View instances, so inherits all their events. Events fired directly from DataTable:
renderTable- fired fromrenderUI, default function creates the<table>and<caption>and fires the other render eventsrenderHead- fired fromrenderTable’s default function IFFheaderViewis set. Default action callsrenderon the ViewrenderFoot- (same)renderBody- (same)addColumn- FromY.DataTable.Mutableextension, fired from the so-named methodremoveColumn- (same)modifyColumn- (same)moveColumn- (same)
Properties
data- the ModelList instancehead- theheaderViewinstance, populated byrenderHead’s default functionbody- (same)foot- (same)_tableNode- Node instance of the<table>element_captionNode- likewise for<caption>_colgroupNode- and for<colgroup>, fromY.DataTable.ColumnWidths_theadNode- you guessed it_tbodyNode- yep, but only one. This might come back to haunt me_tfootNode- predictably_viewConfig- base config object (aka prototype) for…_headerConfig- specific configuration values to pass to theheaderViewconstructor_bodyConfig- specific configuration values to pass to thebodyViewconstructor_footerConfig- specific configuration values to pass to thefooterViewconstructor
Render lifecycle
This is the base rendering; augmented rendering for column widths left out.
renderUIfiresrenderTablerenderTable’sdefaultFncreates the<table>- if
headerViewis set- creates a
<thead> - creates an instance of the
headerClass, passing the_headerConfigobject plus the<thead>as a “container”, anddataas the “modelList” - fires the
renderHeadevent, passing the View instance as payload renderHead’sdefaultFncalls the View’srender()method
- creates a
- repeat for
footerView, thenbodyView bindUIdoes the usual thingsyncUIcreates the<caption>if the attribute is set, and so for the<table>’ssummaryattribute
See the user guide (http://yuilibrary.com/datatable/) for more information.
