Created
April 13, 2012 00:07
-
-
Save lsmith/2372050 to your computer and use it in GitHub Desktop.
Bare bones class for 3.5.0 DataTable's recordType = faster render
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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