* Renders rows based on the table's latest set of data, which was either provided directly as an * input or retrieved through an Observable stream (directly or from a DataSource). * Checks for differences in the data since the last diff to perform only the necessary * changes (add/remove/mo
()
| 729 | * an array, this function will need to be called to render any changes. |
| 730 | */ |
| 731 | renderRows() { |
| 732 | this._renderRows = this._getAllRenderRows(); |
| 733 | const changes = this._dataDiffer.diff(this._renderRows); |
| 734 | if (!changes) { |
| 735 | this._updateNoDataRow(); |
| 736 | this.contentChanged.next(); |
| 737 | return; |
| 738 | } |
| 739 | const viewContainer = this._rowOutlet.viewContainer; |
| 740 | |
| 741 | this._viewRepeater.applyChanges( |
| 742 | changes, |
| 743 | viewContainer, |
| 744 | ( |
| 745 | record: IterableChangeRecord<RenderRow<T>>, |
| 746 | _adjustedPreviousIndex: number | null, |
| 747 | currentIndex: number | null, |
| 748 | ) => this._getEmbeddedViewArgs(record.item, currentIndex!), |
| 749 | record => record.item.data, |
| 750 | (change: _ViewRepeaterItemChange<RenderRow<T>, RowContext<T>>) => { |
| 751 | if (change.operation === _ViewRepeaterOperation.INSERTED && change.context) { |
| 752 | this._renderCellTemplateForItem(change.record.item.rowDef, change.context); |
| 753 | } |
| 754 | }, |
| 755 | ); |
| 756 | |
| 757 | // Update the meta context of a row's context data (index, count, first, last, ...) |
| 758 | this._updateRowIndexContext(); |
| 759 | |
| 760 | // Update rows that did not get added/removed/moved but may have had their identity changed, |
| 761 | // e.g. if trackBy matched data on some property but the actual data reference changed. |
| 762 | changes.forEachIdentityChange((record: IterableChangeRecord<RenderRow<T>>) => { |
| 763 | const rowView = <RowViewRef<T>>viewContainer.get(record.currentIndex!); |
| 764 | rowView.context.$implicit = record.item.data; |
| 765 | }); |
| 766 | |
| 767 | this._updateNoDataRow(); |
| 768 | |
| 769 | this.contentChanged.next(); |
| 770 | this.updateStickyColumnStyles(); |
| 771 | } |
| 772 | |
| 773 | /** Adds a column definition that was not included as part of the content children. */ |
| 774 | addColumnDef(columnDef: CdkColumnDef) { |
no test coverage detected