* 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
()
| 884 | * input. May be called manually for cases where the cell content changes outside of these events. |
| 885 | */ |
| 886 | updateStickyColumnStyles() { |
| 887 | const headerRows = this._getRenderedRows(this._headerRowOutlet); |
| 888 | const dataRows = this._getRenderedRows(this._rowOutlet); |
| 889 | const footerRows = this._getRenderedRows(this._footerRowOutlet); |
| 890 | |
| 891 | // For tables not using a fixed layout, the column widths may change when new rows are rendered. |
| 892 | // In a table using a fixed layout, row content won't affect column width, so sticky styles |
| 893 | // don't need to be cleared unless either the sticky column config changes or one of the row |
| 894 | // defs change. |
| 895 | if ((this._isNativeHtmlTable && !this.fixedLayout) || this._stickyColumnStylesNeedReset) { |
| 896 | // Clear the left and right positioning from all columns in the table across all rows since |
| 897 | // sticky columns span across all table sections (header, data, footer) |
| 898 | this._stickyStyler.clearStickyPositioning( |
| 899 | [...headerRows, ...dataRows, ...footerRows], |
| 900 | ['left', 'right'], |
| 901 | ); |
| 902 | this._stickyColumnStylesNeedReset = false; |
| 903 | } |
| 904 | |
| 905 | // Update the sticky styles for each header row depending on the def's sticky state |
| 906 | headerRows.forEach((headerRow, i) => { |
| 907 | this._addStickyColumnStyles([headerRow], this._headerRowDefs[i]); |
| 908 | }); |
| 909 | |
| 910 | // Update the sticky styles for each data row depending on its def's sticky state |
| 911 | this._rowDefs.forEach(rowDef => { |
| 912 | // Collect all the rows rendered with this row definition. |
| 913 | const rows: HTMLElement[] = []; |
| 914 | for (let i = 0; i < dataRows.length; i++) { |
| 915 | if (this._renderRows[i].rowDef === rowDef) { |
| 916 | rows.push(dataRows[i]); |
| 917 | } |
| 918 | } |
| 919 | |
| 920 | this._addStickyColumnStyles(rows, rowDef); |
| 921 | }); |
| 922 | |
| 923 | // Update the sticky styles for each footer row depending on the def's sticky state |
| 924 | footerRows.forEach((footerRow, i) => { |
| 925 | this._addStickyColumnStyles([footerRow], this._footerRowDefs[i]); |
| 926 | }); |
| 927 | |
| 928 | // Reset the dirty state of the sticky input change since it has been used. |
| 929 | Array.from(this._columnDefsByName.values()).forEach(def => def.resetStickyChanged()); |
| 930 | } |
| 931 | |
| 932 | /** |
| 933 | * Implemented as a part of `StickyPositioningListener`. |
no test coverage detected