@@ -52,7 +52,7 @@ export class ViewportDataGrid<T> extends Common.ObjectWrapper.eventMixin<EventTy
52
52
this . isStriped = striped ;
53
53
let startsWithOdd = true ;
54
54
if ( this . visibleNodes . length ) {
55
- const allChildren = ( this . rootNode ( ) as ViewportDataGridNode < T > ) . flatChildren ( ) ;
55
+ const allChildren = this . filteredNodes ( ) ;
56
56
startsWithOdd = Boolean ( allChildren . indexOf ( this . visibleNodes [ 0 ] ) ) ;
57
57
}
58
58
this . updateStripesClass ( startsWithOdd ) ;
@@ -168,8 +168,7 @@ export class ViewportDataGrid<T> extends Common.ObjectWrapper.eventMixin<EventTy
168
168
visibleNodes : Array < ViewportDataGridNode < T > > ,
169
169
offset : number ,
170
170
} {
171
- const nodes =
172
- ( this . rootNode ( ) as ViewportDataGridNode < T > ) . flatChildren ( ) . filter ( this . testNodeWithFilters . bind ( this ) ) ;
171
+ const nodes = this . filteredNodes ( ) ;
173
172
174
173
if ( this . inline ) {
175
174
return { topPadding : 0 , bottomPadding : 0 , contentHeight : 0 , visibleNodes : nodes , offset : 0 } ;
@@ -210,14 +209,11 @@ export class ViewportDataGrid<T> extends Common.ObjectWrapper.eventMixin<EventTy
210
209
}
211
210
212
211
override getNumberOfRows ( ) : number {
213
- return ( this . rootNode ( ) as ViewportDataGridNode < T > )
214
- . flatChildren ( )
215
- . filter ( this . testNodeWithFilters . bind ( this ) )
216
- . length ;
212
+ return this . filteredNodes ( ) . length ;
217
213
}
218
214
219
215
private contentHeight ( ) : number {
220
- const nodes = ( this . rootNode ( ) as ViewportDataGridNode < T > ) . flatChildren ( ) ;
216
+ const nodes = this . filteredNodes ( ) ;
221
217
let result = 0 ;
222
218
for ( let i = 0 , size = nodes . length ; i < size ; ++ i ) {
223
219
result += nodes [ i ] . nodeSelfHeight ( ) ;
@@ -260,7 +256,7 @@ export class ViewportDataGrid<T> extends Common.ObjectWrapper.eventMixin<EventTy
260
256
let offset = viewportState . offset ;
261
257
262
258
if ( visibleNodes . length ) {
263
- const nodes = ( this . rootNode ( ) as ViewportDataGridNode < T > ) . flatChildren ( ) ;
259
+ const nodes = this . filteredNodes ( ) ;
264
260
const index = nodes . indexOf ( visibleNodes [ 0 ] ) ;
265
261
this . updateStripesClass ( Boolean ( index % 2 ) ) ;
266
262
if ( this . keepScrollingToBottom && index !== - 1 && Boolean ( index % 2 ) !== this . firstVisibleIsStriped ) {
@@ -297,7 +293,7 @@ export class ViewportDataGrid<T> extends Common.ObjectWrapper.eventMixin<EventTy
297
293
}
298
294
299
295
revealViewportNode ( node : ViewportDataGridNode < T > ) : void {
300
- const nodes = ( this . rootNode ( ) as ViewportDataGridNode < T > ) . flatChildren ( ) ;
296
+ const nodes = this . filteredNodes ( ) ;
301
297
const index = nodes . indexOf ( node ) ;
302
298
if ( index === - 1 ) {
303
299
return ;
@@ -317,6 +313,10 @@ export class ViewportDataGrid<T> extends Common.ObjectWrapper.eventMixin<EventTy
317
313
}
318
314
this . scrollContainer . scrollTop = scrollTop ;
319
315
}
316
+
317
+ private filteredNodes ( ) : Array < ViewportDataGridNode < T > > {
318
+ return ( this . rootNode ( ) as ViewportDataGridNode < T > ) . flatChildren ( ) . filter ( this . testNodeWithFilters . bind ( this ) ) ;
319
+ }
320
320
}
321
321
322
322
export const enum Events {
0 commit comments