Skip to content

Instantly share code, notes, and snippets.

@lsmith
Created April 13, 2012 00:07
Show Gist options
  • Save lsmith/2372050 to your computer and use it in GitHub Desktop.
Save lsmith/2372050 to your computer and use it in GitHub Desktop.
Bare bones class for 3.5.0 DataTable's recordType = faster render
// Until some planned performance enhancements are applied to DataTable's infrastructure,
// this is a quick hack to improve rendering performance if it's needed:
// Some quacking will be needed for the various places where duck-typing is used
function DumbRecord(data) {
this.data = data;
this._id = 'record_' + DumbRecord._id++;
this.lists = []; // quack
}
DumbRecord._id = 0;
DumbRecord.prototype = {
_isYUIModel: 'quack',
set: function () { /* quack */ },
addTarget: function () { /* quack */ },
getAttrs: function () { /* quack */ },
get: function (name) {
return name === 'clientId' ? this._id : this.data[name];
},
toJSON: function () { return this.data },
};
var table = new Y.DataTable({
columns: [ ... ],
data: [ ... ],
recordType: DumbRecord
}).render('#over-there');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment