@@ -5,7 +5,7 @@ import { Column, GridOption, SlickEventHandler, ExtensionName } from './../model
5
5
import { ExtensionUtility } from '../extensions/extensionUtility' ;
6
6
import { ExtensionService } from './extension.service' ;
7
7
import { ResizerService } from './resizer.service' ;
8
- import { unsubscribeAllObservables } from './utilities' ;
8
+ import { emptyElement , unsubscribeAllObservables } from './utilities' ;
9
9
import { SharedService } from './shared.service' ;
10
10
11
11
// using external non-typed js libraries
@@ -101,56 +101,64 @@ export class GroupingAndColspanService {
101
101
renderPreHeaderRowGroupingTitles ( ) {
102
102
if ( this . _gridOptions && this . _gridOptions . frozenColumn !== undefined && this . _gridOptions . frozenColumn >= 0 ) {
103
103
// Add column groups to left panel
104
- let $preHeaderPanel = $ ( this . _grid . getPreHeaderPanelLeft ( ) ) ;
105
- this . renderHeaderGroups ( $preHeaderPanel , 0 , this . _gridOptions . frozenColumn + 1 ) ;
104
+ let preHeaderPanelElm = this . _grid . getPreHeaderPanelLeft ( ) ;
105
+ this . renderHeaderGroups ( preHeaderPanelElm , 0 , this . _gridOptions . frozenColumn + 1 ) ;
106
106
107
107
// Add column groups to right panel
108
- $preHeaderPanel = $ ( this . _grid . getPreHeaderPanelRight ( ) ) ;
109
- this . renderHeaderGroups ( $preHeaderPanel , this . _gridOptions . frozenColumn + 1 , this . _columnDefinitions . length ) ;
108
+ preHeaderPanelElm = this . _grid . getPreHeaderPanelRight ( ) ;
109
+ this . renderHeaderGroups ( preHeaderPanelElm , this . _gridOptions ? .frozenColumn + 1 , this . _columnDefinitions . length ) ;
110
110
} else {
111
111
// regular grid (not a frozen grid)
112
- const $preHeaderPanel = $ ( this . _grid . getPreHeaderPanel ( ) ) ;
113
- this . renderHeaderGroups ( $preHeaderPanel , 0 , this . _columnDefinitions . length ) ;
112
+ const preHeaderPanelElm = this . _grid . getPreHeaderPanel ( ) ;
113
+ this . renderHeaderGroups ( preHeaderPanelElm , 0 , this . _columnDefinitions . length ) ;
114
114
}
115
115
}
116
116
117
- renderHeaderGroups ( preHeaderPanel : any , start : number , end : number ) {
118
- preHeaderPanel . empty ( )
119
- . addClass ( 'slick-header-columns' )
120
- . css ( 'left' , '-1000px' )
121
- . width ( this . _grid . getHeadersWidth ( ) ) ;
122
- preHeaderPanel . parent ( ) . addClass ( 'slick-header' ) ;
117
+ renderHeaderGroups ( preHeaderPanel : HTMLElement , start : number , end : number ) {
118
+ emptyElement ( preHeaderPanel ) ;
119
+ preHeaderPanel . className = 'slick-header-columns' ;
120
+ preHeaderPanel . style . left = '-1000px' ;
121
+ preHeaderPanel . style . width = `${ this . _grid . getHeadersWidth ( ) } px` ;
122
+
123
+ if ( preHeaderPanel . parentElement ) {
124
+ preHeaderPanel . parentElement . classList . add ( 'slick-header' ) ;
125
+ }
123
126
124
127
const headerColumnWidthDiff = this . _grid . getHeaderColumnWidthDiff ( ) ;
125
128
126
129
let colDef ;
127
- let header ;
130
+ let headerElm : HTMLDivElement | null = null ;
128
131
let lastColumnGroup = '' ;
129
132
let widthTotal = 0 ;
130
- const frozenHeaderWidthCalcDifferential = this . _gridOptions && this . _gridOptions . frozenHeaderWidthCalcDifferential || 0 ;
131
- const isFrozenGrid = ( this . _gridOptions && ( this . _gridOptions . frozenColumn !== undefined && this . _gridOptions . frozenColumn >= 0 ) ) ;
133
+ const frozenHeaderWidthCalcDifferential = this . _gridOptions ?. frozenHeaderWidthCalcDifferential ?? 0 ;
134
+ const isFrozenGrid = ( this . _gridOptions ?. frozenColumn !== undefined && this . _gridOptions . frozenColumn >= 0 ) ;
132
135
133
136
for ( let i = start ; i < end ; i ++ ) {
134
137
colDef = this . _columnDefinitions [ i ] ;
135
138
if ( colDef ) {
136
139
if ( lastColumnGroup === colDef . columnGroup && i > 0 ) {
137
140
widthTotal += colDef . width || 0 ;
138
- if ( header && header . width ) {
139
- header . width ( widthTotal - headerColumnWidthDiff - frozenHeaderWidthCalcDifferential ) ; // remove possible frozen border
141
+ if ( headerElm ?. style ) {
142
+ headerElm . style . width = ` ${ widthTotal - headerColumnWidthDiff - frozenHeaderWidthCalcDifferential } px` ; // remove possible frozen border
140
143
}
141
144
} else {
142
145
widthTotal = colDef . width || 0 ;
143
- header = $ ( `<div class="ui-state-default slick-header-column ${ isFrozenGrid ? 'frozen' : '' } " />` )
144
- . html ( `<span class="slick-column-name">${ colDef . columnGroup || '' } </span>` )
145
- . width ( widthTotal - headerColumnWidthDiff )
146
- . appendTo ( preHeaderPanel ) ;
146
+ headerElm = document . createElement ( 'div' ) ;
147
+ headerElm . className = `ui-state-default slick-header-column ${ isFrozenGrid ? 'frozen' : '' } ` ;
148
+ headerElm . style . width = `${ widthTotal - headerColumnWidthDiff } px` ;
149
+
150
+ const spanColumnNameElm = document . createElement ( 'span' ) ;
151
+ spanColumnNameElm . className = 'slick-column-name' ;
152
+ spanColumnNameElm . textContent = colDef . columnGroup || '' ;
153
+
154
+ headerElm . appendChild ( spanColumnNameElm ) ;
155
+ preHeaderPanel . appendChild ( headerElm ) ;
147
156
}
148
157
lastColumnGroup = colDef . columnGroup || '' ;
149
158
}
150
159
}
151
160
}
152
161
153
-
154
162
/** Translate Column Group texts and re-render them afterward. */
155
163
translateGroupingAndColSpan ( ) {
156
164
const currentColumnDefinitions = this . _grid . getColumns ( ) ;
0 commit comments