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
headerView
toY.DataTable.HeaderView
andbodyView
toY.DataTable.BodyView
- Widget generated from
Y.DataTable
Y.DataTable.Base
Subclass- Constructor with all
use()
d features - Namespace for DT-specific extensions and component classes
Y.DataTable.HeaderView
Y.View
subclass- Renders the content of the
<thead>
Y.DataTable.BodyView
Y.View
subclass- Renders the content of the
<tbody>
Y.DataTable.ColumnWidths
- Class extension
- Renders
<colgroup>
and<col>
s - Supports
width
configuration 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 IFFheaderView
is set. Default action callsrender
on the ViewrenderFoot
- (same)renderBody
- (same)addColumn
- FromY.DataTable.Mutable
extension, fired from the so-named methodremoveColumn
- (same)modifyColumn
- (same)moveColumn
- (same)
Properties
data
- the ModelList instancehead
- theheaderView
instance, 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 theheaderView
constructor_bodyConfig
- specific configuration values to pass to thebodyView
constructor_footerConfig
- specific configuration values to pass to thefooterView
constructor
Render lifecycle
This is the base rendering; augmented rendering for column widths left out.
renderUI
firesrenderTable
renderTable
’sdefaultFn
creates the<table>
- if
headerView
is set- creates a
<thead>
- creates an instance of the
headerClass
, passing the_headerConfig
object plus the<thead>
as a “container”, anddata
as the “modelList” - fires the
renderHead
event, passing the View instance as payload renderHead
’sdefaultFn
calls the View’srender()
method
- creates a
- repeat for
footerView
, thenbodyView
bindUI
does the usual thingsyncUI
creates the<caption>
if the attribute is set, and so for the<table>
’ssummary
attribute
See the user guide (http://yuilibrary.com/datatable/) for more information.