Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 29 additions & 27 deletions iron-data-table.html
Original file line number Diff line number Diff line change
Expand Up @@ -477,33 +477,35 @@
'_resetData(dataSource, filter.*, sortOrder.*)'
],

created: function() {
this._observer = Polymer.dom(this).observeNodes(function(info) {
var hasColumns = function(node) {
return (node.nodeType === Node.ELEMENT_NODE && node.tagName.toUpperCase() === 'DATA-TABLE-COLUMN');
};

var hasDetails = function(node) {
return (node.nodeType === Node.ELEMENT_NODE &&
node.tagName.toUpperCase() === 'TEMPLATE' && node.hasAttribute('is') &&
node.getAttribute('is') === 'row-detail');
};

if (info.addedNodes.filter(hasColumns).length > 0 ||
info.removedNodes.filter(hasColumns).length > 0) {
this.set('columns', this.getContentChildren('[select=data-table-column]'));
this.notifyResize();
}

if (info.addedNodes.filter(hasDetails).length > 0) {
this.set('rowDetail', this.getContentChildren('[select="template[is=row-detail]"]')[0]);

// assuming parent element is always a Polymer element.
// set dataHost to the same context the template was declared in
var parent = Polymer.dom(this.rowDetail).parentNode;
this.rowDetail._rootDataHost = parent.dataHost ? (parent.dataHost._rootDataHost || parent.dataHost) : parent;
}

attached: function() {
this.async(function(){
this._observer = Polymer.dom(this).observeNodes(function(info) {
var hasColumns = function(node) {
return (node.nodeType === Node.ELEMENT_NODE && node.tagName.toUpperCase() === 'DATA-TABLE-COLUMN');
};

var hasDetails = function(node) {
return (node.nodeType === Node.ELEMENT_NODE &&
node.tagName.toUpperCase() === 'TEMPLATE' && node.hasAttribute('is') &&
node.getAttribute('is') === 'row-detail');
};

if (info.addedNodes.filter(hasColumns).length > 0 ||
info.removedNodes.filter(hasColumns).length > 0) {
this.set('columns', this.getContentChildren('[select=data-table-column]'));
this.notifyResize();
}

if (info.addedNodes.filter(hasDetails).length > 0) {
this.set('rowDetail', this.getContentChildren('[select="template[is=row-detail]"]')[0]);

// assuming parent element is always a Polymer element.
// set dataHost to the same context the template was declared in
var parent = Polymer.dom(this.rowDetail).parentNode;
this.rowDetail._rootDataHost = parent.dataHost ? (parent.dataHost._rootDataHost || parent.dataHost) : parent;
}

}.bind(this));
}.bind(this));
},

Expand Down