body.js revision d15134141197c4fc93eb6094020e03eb72aa8d73
828c58761d90445b8b9d20a82d85dc1479317f71TrippY.namespace('DataTable').BodyView = Y.Base.create('tableBody', Y.View, [], {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp // -- Instance properties -------------------------------------------------
ed59119d8c00addb07c7ee6c8aefcd1d9cb876f1Tripp '<tbody class="{classes}">{content}</tbody>',
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp '<tr id="{clientId}" class="{rowClasses}">' +
828c58761d90445b8b9d20a82d85dc1479317f71Tripp '{content}' +
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp '<td headers="{headers}" class="{classes}" {attributes}>' +
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp '<div class="{linerClass}">' +
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp '{content}' +
e7c7565d9550eaa87043aef0df77125ada996deaTripp // -- Public methods ------------------------------------------------------
828c58761d90445b8b9d20a82d85dc1479317f71Tripp bindUI: function () {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp this.host.after('columnChange', this._afterColumnChange),
828c58761d90445b8b9d20a82d85dc1479317f71Tripp destructor: function () {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp this.host.after('columnsChange', this._afterColumnsChange);
828c58761d90445b8b9d20a82d85dc1479317f71Tripp render: function () {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp existing = table.one('> .' + this.host.getClassName('data')),
828c58761d90445b8b9d20a82d85dc1479317f71Tripp replace = existing && (!tbody || !tbody.compareTo(existing));
828c58761d90445b8b9d20a82d85dc1479317f71Tripp // Needed for mutation
828c58761d90445b8b9d20a82d85dc1479317f71Tripp return this;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp // -- Protected and private methods ---------------------------------------
828c58761d90445b8b9d20a82d85dc1479317f71Tripp _afterColumnsChange: function (e) {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp existing = this.table.one('> .' + this.host.getClassName('data')),
828c58761d90445b8b9d20a82d85dc1479317f71Tripp newCols, i, len, colA, colB, colAIndex, colBIndex, redraw;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp // TODO: can't call render() because it doesn't replace the same
828c58761d90445b8b9d20a82d85dc1479317f71Tripp // tbody, and it calls bindUI()
828c58761d90445b8b9d20a82d85dc1479317f71Tripp _afterDataChange: function (e) {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp // Only iterate the ModelList again if there are nodeFormatters
828c58761d90445b8b9d20a82d85dc1479317f71Tripp if (keep === false) {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp // Remove from the Node cache to reduce
828c58761d90445b8b9d20a82d85dc1479317f71Tripp // memory footprint. This also purges events,
828c58761d90445b8b9d20a82d85dc1479317f71Tripp // which you shouldn't be scoping to a cell
828c58761d90445b8b9d20a82d85dc1479317f71Tripp // anyway. You've been warned. Incidentally,
828c58761d90445b8b9d20a82d85dc1479317f71Tripp // you should always return false. Just sayin.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp i, len, col, key, value, formatterData, attributes, attr;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp //attributes: {}
828c58761d90445b8b9d20a82d85dc1479317f71Tripp // Formatters can either return a value
828c58761d90445b8b9d20a82d85dc1479317f71Tripp // or update the value property of the data obj passed
828c58761d90445b8b9d20a82d85dc1479317f71Tripp // Defer all node decoration to the formatter
828c58761d90445b8b9d20a82d85dc1479317f71Tripp // Custom Array.indexOf to search by property rather than object
828c58761d90445b8b9d20a82d85dc1479317f71Tripp // identity. Columns may be reset with new objects with the same props.
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp _isModifiedColumn: function (a, b) {
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp _isSameColumn: function (a, b) {
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp return (a && b) && (
66ca16dd76367c074fe4df1dcf7b555489a9bf85Tripp (a.nodeFormatter && a.nodeFormatter === b.nodeFormatter))));