@@ -43,7 +43,6 @@ export class GridComponent implements OnInit {
4343 this . live = true ;
4444 this . disabled = false ;
4545 this . sortedByTrackProgress = true ;
46-
4746 this . SortByTrackProgress ( ) ;
4847 }
4948 private SortByTrackProgress ( ) {
@@ -62,7 +61,9 @@ export class GridComponent implements OnInit {
6261
6362 private tickerFunc ( tick ) {
6463 if ( tick % 3 === 0 ) {
65- const idx = this . getRandomNumber ( 5 , 0 ) ;
64+ const size = this . grid1 . dataContainer . transformedData . length - 1 ;
65+ const min = Math . min ( 5 , size ) ;
66+ const idx = this . getRandomNumber ( min , 0 ) ;
6667 const newValue = this . grid1 . getCell ( idx , 'TrackProgress' ) . dataItem + 15 ;
6768
6869 if ( newValue >= 100 ) {
@@ -96,8 +97,10 @@ export class GridComponent implements OnInit {
9697 }
9798 private resetPositions ( ) {
9899 let index = 0 ;
100+ const size = this . grid1 . dataContainer . transformedData . length - 1 ;
101+ const min = Math . min ( size , 6 ) ;
99102
100- while ( index < 6 ) {
103+ while ( index < min ) {
101104 this . grid1 . updateCell ( index , 'Position' , 'current' ) ;
102105 index ++ ;
103106 }
@@ -143,9 +146,21 @@ export class GridComponent implements OnInit {
143146 } ) ;
144147
145148 if ( this . grid1 . paginator . isFirst && this . sortedByTrackProgress ) {
146- rowElements . slice ( 1 , 4 ) . forEach ( ( tr : HTMLElement ) => tr . style . backgroundColor = '#E7F5FE' ) ;
149+ const size = this . grid1 . dataContainer . transformedData . length - 1 ;
150+ const min = Math . min ( 3 , size ) ;
151+ for ( let i = 0 ; i < min ; i ++ ) {
152+ if ( this . grid1 . getRow ( i ) . record . Id < 4 ) {
153+ this . grid1 . getRow ( i ) . element . style . backgroundColor = '#E7F5FE' ;
154+ }
155+ }
147156 }
148157 } , 1 ) ;
158+
159+ if ( this . sortedByTrackProgress ) {
160+ this . localData . forEach ( ( value , index ) => {
161+ value . Id = index + 1 ;
162+ } ) ;
163+ }
149164 }
150165
151166
@@ -157,7 +172,6 @@ export class GridComponent implements OnInit {
157172 const direction = event . direction ;
158173
159174 this . sortedByTrackProgress = false ;
160-
161175 if ( event . column . field === 'Id' && direction === 0 ) {
162176 const column = this . grid1 . getColumnByField ( 'TrackProgress' ) ;
163177 this . grid1 . sortColumn ( column , SortingDirection . Desc ) ;
0 commit comments