These are my early thoughts on how to structure DataTable in 3.5.0. Feedback is welcome in the comments.
new Y.DataTable({...});
new Y.DataTable.Base({...});
Y.DataTable.Base = Y.Base.create('datatable', Y.Widget, [Y.DataTable.Core]);
Y.DataTable = Y.mix(
Y.Base.create('datatable', Y.DataTable.Base, []),
Y.DataTable, true);
Class extensions CAN (if non-invasive by default)
Y.Base.mix(Y.DataTable, [ Y.DataTable.Sortable ]);
new Y.DataTable({
data: [{ ... }, { ... }, ... ]
data: modelList
data: {
source: url, function, xml
type: 'json'
schema: { ... }
}
columns: (optional) [ key, key, { key: key, config: stuff, ... }, ... ]
recordType: (optional) ModelClass
headerView: (optional) ViewClass
bodyView: (optional) ViewClass
footerView: (optional) ViewClass
summary: (optional) 'string'
caption: (optional) 'string'
});
instance
.data = modelListInstance
.head = viewInstance
.body = viewInstance
.foot = viewInstance
-
Y.DataTable.Core
Everything added to Y.Widget to make DataTable.Base
-
Y.DataTable.HeaderView
-
Y.DataTable.BodyView
-
Y.DataTable.FooterView
Used by DataTable(.Base) to render the table contents.
Referenced via configuration, not composition.
-
Y.DataTable.Source
Optional class extension.
Adds support
data
config to generate ML with DataSource load. -
Y.DataTable.Scrollable
Optional class extension.
Adds support for scrolling table. May be used to create a third instantiable class.
-
Y.DataTable.ScrollingBodyView
Used in place of DataTable.BodyView to render the scrolling table. May not be necessary?
-
Y.DataTable.Sortable
Adds support for sorting headers and sortable config.
instance.render(...)
- build <table> (markup only or off DOM node?)
- instantiate header, body, footer views passing
- the DT instance
- the created table?
- the
data
ModelList?
- call each view's render()
Logic for reacting to user input is moved to the View classes
Concern: string based rendering would have viewX.render() return a string or populate a property, but it has requirements of the DT renderer
instance.load(...)
Pass through to this.data.load(...). Let the ModelList be responsible for data interaction.
- No ModelList is provided in
data
configuration AND - No
recordType
is provided in configuration
- Use the first item in the data array to build ATTRS and Y.Base.create(...)
- If data is empty, use columns?
Looks like a great start at a complete rewrite of DT. I'm probably a little out of my element here ( !== professional developer) but have a lot of hours / sweat invested in DT projects.
I agree with mosen's remarks regarding Sortable / Scrollable and other combinations of features (pagination!) ... the component will need to incorporate the union of capabilities in some fashion (e.g. a sortable and scrollable and inline editable and paginated capability). I assume from the remarks above that this is a given.
I'm not yet proficient or smart enough to understand if the YUI3 ML framework will provide a mechanism for designing a data abstraction layer to permit plugging in back-end (i.e. server) updating of data from cell editing. Perhaps something like asyncSubmitter, just more elegant.
As a related remark, I think mosen mentioned this, but will there be ability to "update" (i.e. render) just a single record / TR? What if the server sends an updated record to the DT (i.e. like a stock price update), could this capability be incorporated in some way?
A big missing element of YUI2 DT IMHO has been a clean data "grouping" capability, wherein a TR forms a parent-child relationship to underlying data. There have been many incarnations of "nested" and "treeble" concepts but the NEED is to have a smart DT that can provide "grouping" of lower level data in either the header or the footer. Seems like the "headerView, bodyView, footerView" concept is clean ... is there any way to provide capability to chain or allow a single row to contain another DT with it's own headerView, bodyView, footerView, etc... Note the parent-child relationship would want to be "data-rich", wherein for example, a summary group TR with numeric totals would actively update upon a child record value changing.
Certainly some of my remarks if ever implemented would be relegated to 3.5+ release or later if at all, but maybe some design input for "wants and needs" could be helpful right now at the preliminary design stage for DT.