migration.mustache revision 2443526ef32df6fc65a30dc74f4f91ee12562f6c
3f8adfdf712dad8059e3f5be6ff4f4a794386ce4nd margin: 1ex 0;
031b91a62d25106ae69d4693475c79618dd5e884fielding white-space: nowrap;
031b91a62d25106ae69d4693475c79618dd5e884fielding background: #fcfbfa;
031b91a62d25106ae69d4693475c79618dd5e884fielding border: 1px solid #d0d5ec;
031b91a62d25106ae69d4693475c79618dd5e884fielding padding: 0 3px;
3f8adfdf712dad8059e3f5be6ff4f4a794386ce4nd border-color: #efeeed;
3f8adfdf712dad8059e3f5be6ff4f4a794386ce4nd.yui3-skin-sam table {
3f8adfdf712dad8059e3f5be6ff4f4a794386ce4nd width: auto;
3f8adfdf712dad8059e3f5be6ff4f4a794386ce4nd.yui3-skin-sam td,
3f8adfdf712dad8059e3f5be6ff4f4a794386ce4nd.yui3-skin-sam th {
3f8adfdf712dad8059e3f5be6ff4f4a794386ce4nd border: 0 none;
3f8adfdf712dad8059e3f5be6ff4f4a794386ce4nd.demo { width: 40%; }
3f8adfdf712dad8059e3f5be6ff4f4a794386ce4nd.details { width: 60%; }
3f8adfdf712dad8059e3f5be6ff4f4a794386ce4nd.before, .after { width: 47%; }
3f8adfdf712dad8059e3f5be6ff4f4a794386ce4nd margin-left: 5%;
3f8adfdf712dad8059e3f5be6ff4f4a794386ce4nd#quickref code em {
3f8adfdf712dad8059e3f5be6ff4f4a794386ce4nd color: #900;
3f8adfdf712dad8059e3f5be6ff4f4a794386ce4nd#quickref code strong {
3f8adfdf712dad8059e3f5be6ff4f4a794386ce4nd color: #090;
3f8adfdf712dad8059e3f5be6ff4f4a794386ce4nd margin-top: 0;
3f8adfdf712dad8059e3f5be6ff4f4a794386ce4nd margin-bottom: 0;
3f8adfdf712dad8059e3f5be6ff4f4a794386ce4nd color: #b00;
3f8adfdf712dad8059e3f5be6ff4f4a794386ce4nd<div class="intro">
3f8adfdf712dad8059e3f5be6ff4f4a794386ce4nd DataTable and supporting modules were rebuilt in version 3.5.0. The
3f8adfdf712dad8059e3f5be6ff4f4a794386ce4nd new architecture is <strong>not fully backward compatible</strong> with
3f8adfdf712dad8059e3f5be6ff4f4a794386ce4nd versions 3.4.1 and prior. This guide is to help answer questions that
3f8adfdf712dad8059e3f5be6ff4f4a794386ce4nd may come up when upgrading to the lastest version.
3f8adfdf712dad8059e3f5be6ff4f4a794386ce4nd This guide focuses on 3.4.1 API compatibility. It <strong>does not
3f8adfdf712dad8059e3f5be6ff4f4a794386ce4nd describe new features added in 3.5.0</strong> (there were a lot).
3f8adfdf712dad8059e3f5be6ff4f4a794386ce4nd Refer to the updated <a href="index.html">DataTable user guide</a> for
3f8adfdf712dad8059e3f5be6ff4f4a794386ce4nd If you are unable to upgrade due to unresolvable issues, you can use the
3f8adfdf712dad8059e3f5be6ff4f4a794386ce4nd <a href="../datatable-deprecated/index.html">`datatable-deprecated`</a>
3f8adfdf712dad8059e3f5be6ff4f4a794386ce4nd module suite, which is equivalent to the 3.4.1 implementation. But be
3f8adfdf712dad8059e3f5be6ff4f4a794386ce4nd aware that these modules will be removed in a future version of YUI.
3f8adfdf712dad8059e3f5be6ff4f4a794386ce4nd<h2 id="overview">Overview of API changes from 3.4.1</h2>
3f8adfdf712dad8059e3f5be6ff4f4a794386ce4nd The architectural change resulted in the deprecation, replacement, or
3f8adfdf712dad8059e3f5be6ff4f4a794386ce4nd removal of nearly all attributes and properties from the version 3.4.1
3f8adfdf712dad8059e3f5be6ff4f4a794386ce4nd implementation. Here is a quick list of the changes most likely to affect
3f8adfdf712dad8059e3f5be6ff4f4a794386ce4nd your upgrade:
3f8adfdf712dad8059e3f5be6ff4f4a794386ce4nd<ol id="quickref">
3f8adfdf712dad8059e3f5be6ff4f4a794386ce4nd <code>new <em>Y.DataTable.Base</em>(...)</code> →
3f8adfdf712dad8059e3f5be6ff4f4a794386ce4nd <code>new <strong>Y.DataTable</strong>({ ... })</code>
3f8adfdf712dad8059e3f5be6ff4f4a794386ce4nd <div class="yui3-g">
3f8adfdf712dad8059e3f5be6ff4f4a794386ce4nd <div class="yui3-u">
3f8adfdf712dad8059e3f5be6ff4f4a794386ce4nd columnset: [ ... ],
3f8adfdf712dad8059e3f5be6ff4f4a794386ce4nd recordset: [ ... ]
3f8adfdf712dad8059e3f5be6ff4f4a794386ce4nd <p class="yui3-u" style="line-height: 72px; margin: 0 1em;">→</p>
3f8adfdf712dad8059e3f5be6ff4f4a794386ce4nd <div class="yui3-u">
new Y.DataTable({
<a href="index.html#sorting">the user guide</a>
<a href="index.html#scrolling">the user guide</a>
<a href="index.html#scrolling">the user guide</a>
As of 3.5.0, `Y.DataTable` is no longer just a namespace, but is now the
var table = new Y.DataTable({
return years - (o.value < now);
The `Y.DataTable.Base` class still exists, but is useful primarily as a
superclass for extension. The attributes of `Y.DataTable.Base` are the
same as those of `Y.DataTable`, less any attributes added by class
or override the `Y.DataTable.BodyView` instance's `CELL_TEMPLATE`.
or override the `Y.DataTable.HeaderView` instance's `CELL_TEMPLATE`.
the `Y.DataTable.BodyView` instance's `ROW_TEMPLATE`.
`o.column` in the formatter parameter is now <a href="#columns">the
than a `Y.Column` instance.
`o.record` in the formatter parameter is now <a href="#data">a Model
instance</a> instead of a `Y.Record` instance.
<a href="index.html#nodeformatter">`nodeFormatter`</a>s.
var table = new Y.DataTable.Base({
if (o.value > 4) {
o.classnames += "spendy";
return '$' + o.value.toFixed(2);
var cell = this.createCell(o);
if (o.value > 4) {
cell.addClass('spendy');
var table = new Y.DataTable({
if (o.value > 4) {
o.className += "spendy";
return '$' + o.value.toFixed(2);
if (o.value > 4) {
o.cell.addClass('spendy');
Read the <a href="index.html#formatters">Formatting Cell Data</a> section in
var table = new Y.DataTable({
var columns = table.get('columns'); // => Array, not Columnset instance
table.set('columnset', [ ... (new column configurations) ... ]);
var columnset = table.get('columnset'); // => Array, not Columnset instance
See the <a href="index.html#columns">Column configuration</a> section in
a `Y.Recordset` instance</em>.
var table = new Y.DataTable({
var data = table.get('data'); // => ModelList instance
table.set('recordset', [ ... (new data records) ... ]);
var recordset = table.get('recordset'); // => ModelList, not Recordset
`Y.Record` stores all values in a single attribute named `data`, where `Y.Model` uses individual attributes for each value.
// Y.Record
var record = oldTable.get('recordset').item(0);
record.getValue('birthdate'); // => Date(1940, 1, 6)
record.get('data').birthdate; // => same
// Y.Model
var model = newTable.getRecord(0);
model.get('birthdate'); // => Date(1940, 1, 6)
<strong>This change breaks column/record keys that contain periods</strong>.
that is parsed by `Y.Plugin.DataSourceJSONSchema`, use the `locator`
var table = new Y.DataTable.Base({
{ key: "Product.Name", label: "Product" },
{ key: "Product.Price", label: "Price" }
}).plug(Y.Plugin.DataTableDataSource, {
datasource: new Y.DataSource.IO({
source: "/service/price-list"
}).plug(Y.Plugin.DataSourceJSONSchema, {
{ key: "Product.Name" },
{ key: "Product.Price" }
table.datasource.load(...);
var table = new Y.DataTable({
}).plug(Y.Plugin.DataTableDataSource, {
datasource: new Y.DataSource.IO({
source: "/service/price-list"
}).plug(Y.Plugin.DataSourceJSONSchema, {
locator: "Product.Name" },
locator: "Product.Price" }
table.datasource.load(...);
<dt>`Y.Plugin.RecordsetSort`</dt>
This plugin was formerly applied by the `Y.Plugin.DataTableSort` plugin
<dt>`Y.Plugin.RecordsetFilter`</dt>
<dt>`Y.Plugin.RecordsetIndexer`</dt>
<a href="../model/index.html">the Model user guide</a> for more
extensions for `Y.DataTable`. Simply including the `datatable-sort` or
var table = new Y.DataTable({
table.render('#over-there');
var table = new Y.DataTable.Base({
table.render('#sort-demo');
var table = new Y.DataTable({
table.render('#sort-demo');
table.sort("name");
var table = new Y.DataTable({
var table = new Y.DataTable({
var table = new Y.DataTable({ ... }).render("#over-there");
table._sortHandle = table.delegate(["dblclick", "keydown"],
See the <a href="index.html#sorting">Column Sorting section</a> of the
(now deprecated) `Y.Plugin.DataTableScroll` plugin.
var table = new Y.DataTable.Base({
table.render("#over-there");
var table = new Y.DataTable({
<th id="(guid)" colspan="1" rowspan="1" class="yui3-datatable-header yui3-datatable-first-header yui3-datatable-col-id" scope="col" data-yui3-col-id="id">
<th id="(guid)" colspan="1" rowspan="1" class="yui3-datatable-header yui3-datatable-col-name" scope="col" data-yui3-col-id="name">
<th id="(guid)" colspan="1" rowspan="1" class="yui3-datatable-header yui3-datatable-col-price" scope="col" data-yui3-col-id="price">
something important, please <a href="/projects/yui3/newticket">file a
<a href="/forum">forums</a>, and the #yui IRC channel on freenode.net.