Creates or removes the no data row, depending on whether any data is being shown.
()
| 1564 | |
| 1565 | /** Creates or removes the no data row, depending on whether any data is being shown. */ |
| 1566 | private _updateNoDataRow() { |
| 1567 | const noDataRow = this._customNoDataRow || this._noDataRow; |
| 1568 | |
| 1569 | if (!noDataRow) { |
| 1570 | return; |
| 1571 | } |
| 1572 | |
| 1573 | const shouldShow = this._rowOutlet.viewContainer.length === 0; |
| 1574 | |
| 1575 | if (shouldShow === this._isShowingNoDataRow) { |
| 1576 | return; |
| 1577 | } |
| 1578 | |
| 1579 | const container = this._noDataRowOutlet.viewContainer; |
| 1580 | |
| 1581 | if (shouldShow) { |
| 1582 | const view = container.createEmbeddedView(noDataRow.templateRef); |
| 1583 | const rootNode: HTMLElement | undefined = view.rootNodes[0]; |
| 1584 | |
| 1585 | // Only add the attributes if we have a single root node since it's hard |
| 1586 | // to figure out which one to add it to when there are multiple. |
| 1587 | if (view.rootNodes.length === 1 && rootNode?.nodeType === this._document.ELEMENT_NODE) { |
| 1588 | rootNode.setAttribute('role', 'row'); |
| 1589 | rootNode.classList.add(...noDataRow._contentClassNames); |
| 1590 | |
| 1591 | const cells = rootNode.querySelectorAll(noDataRow._cellSelector); |
| 1592 | |
| 1593 | for (let i = 0; i < cells.length; i++) { |
| 1594 | cells[i].classList.add(...noDataRow._cellClassNames); |
| 1595 | } |
| 1596 | } |
| 1597 | } else { |
| 1598 | container.clear(); |
| 1599 | } |
| 1600 | |
| 1601 | this._isShowingNoDataRow = shouldShow; |
| 1602 | |
| 1603 | this._changeDetectorRef.markForCheck(); |
| 1604 | } |
| 1605 | |
| 1606 | /** |
| 1607 | * Measures the size of the rendered range in the table. |
no test coverage detected