Creates or removes the no data row, depending on whether any data is being shown.
()
| 1582 | |
| 1583 | /** Creates or removes the no data row, depending on whether any data is being shown. */ |
| 1584 | private _updateNoDataRow() { |
| 1585 | const noDataRow = this._customNoDataRow || this._noDataRow; |
| 1586 | |
| 1587 | if (!noDataRow) { |
| 1588 | return; |
| 1589 | } |
| 1590 | |
| 1591 | const shouldShow = this._rowOutlet.viewContainer.length === 0; |
| 1592 | |
| 1593 | if (shouldShow === this._isShowingNoDataRow) { |
| 1594 | return; |
| 1595 | } |
| 1596 | |
| 1597 | const container = this._noDataRowOutlet.viewContainer; |
| 1598 | |
| 1599 | if (shouldShow) { |
| 1600 | const view = container.createEmbeddedView(noDataRow.templateRef); |
| 1601 | const rootNode: HTMLElement | undefined = view.rootNodes[0]; |
| 1602 | |
| 1603 | // Only add the attributes if we have a single root node since it's hard |
| 1604 | // to figure out which one to add it to when there are multiple. |
| 1605 | if (view.rootNodes.length === 1 && rootNode?.nodeType === this._document.ELEMENT_NODE) { |
| 1606 | rootNode.setAttribute('role', 'row'); |
| 1607 | rootNode.classList.add(...noDataRow._contentClassNames); |
| 1608 | |
| 1609 | const cells = rootNode.querySelectorAll(noDataRow._cellSelector); |
| 1610 | |
| 1611 | for (let i = 0; i < cells.length; i++) { |
| 1612 | cells[i].classList.add(...noDataRow._cellClassNames); |
| 1613 | } |
| 1614 | } |
| 1615 | } else { |
| 1616 | container.clear(); |
| 1617 | } |
| 1618 | |
| 1619 | this._isShowingNoDataRow = shouldShow; |
| 1620 | |
| 1621 | this._changeDetectorRef.markForCheck(); |
| 1622 | } |
| 1623 | |
| 1624 | /** |
| 1625 | * Measures the size of the rendered range in the table. |
no test coverage detected