MCPcopy Create free account
hub / github.com/angular/components / updateStickyColumnStyles

Method updateStickyColumnStyles

src/cdk/table/table.ts:904–948  ·  view source on GitHub ↗

* Updates the column sticky styles. First resets all applied styles with respect to the cells * sticking to the left and right. Then sticky styles are added for the left and right according * to the column definitions for each cell in each row. This is automatically called when * the data s

()

Source from the content-addressed store, hash-verified

902 * input. May be called manually for cases where the cell content changes outside of these events.
903 */
904 updateStickyColumnStyles() {
905 const headerRows = this._getRenderedRows(this._headerRowOutlet);
906 const dataRows = this._getRenderedRows(this._rowOutlet);
907 const footerRows = this._getRenderedRows(this._footerRowOutlet);
908
909 // For tables not using a fixed layout, the column widths may change when new rows are rendered.
910 // In a table using a fixed layout, row content won't affect column width, so sticky styles
911 // don't need to be cleared unless either the sticky column config changes or one of the row
912 // defs change.
913 if ((this._isNativeHtmlTable && !this.fixedLayout) || this._stickyColumnStylesNeedReset) {
914 // Clear the left and right positioning from all columns in the table across all rows since
915 // sticky columns span across all table sections (header, data, footer)
916 this._stickyStyler.clearStickyPositioning(
917 [...headerRows, ...dataRows, ...footerRows],
918 ['left', 'right'],
919 );
920 this._stickyColumnStylesNeedReset = false;
921 }
922
923 // Update the sticky styles for each header row depending on the def's sticky state
924 headerRows.forEach((headerRow, i) => {
925 this._addStickyColumnStyles([headerRow], this._headerRowDefs[i]);
926 });
927
928 // Update the sticky styles for each data row depending on its def's sticky state
929 this._rowDefs.forEach(rowDef => {
930 // Collect all the rows rendered with this row definition.
931 const rows: HTMLElement[] = [];
932 for (let i = 0; i < dataRows.length; i++) {
933 if (this._renderRows[i].rowDef === rowDef) {
934 rows.push(dataRows[i]);
935 }
936 }
937
938 this._addStickyColumnStyles(rows, rowDef);
939 });
940
941 // Update the sticky styles for each footer row depending on the def's sticky state
942 footerRows.forEach((footerRow, i) => {
943 this._addStickyColumnStyles([footerRow], this._footerRowDefs[i]);
944 });
945
946 // Reset the dirty state of the sticky input change since it has been used.
947 Array.from(this._columnDefsByName.values()).forEach(def => def.resetStickyChanged());
948 }
949
950 /**
951 * Implemented as a part of `StickyPositioningListener`.

Callers 6

multiTemplateDataRowsMethod · 0.95
renderRowsMethod · 0.95
_renderMethod · 0.95
_checkStickyStatesMethod · 0.95
_setupStickyStylerMethod · 0.95

Calls 5

_getRenderedRowsMethod · 0.95
pushMethod · 0.65
resetStickyChangedMethod · 0.65

Tested by

no test coverage detected