@@ -10,13 +10,12 @@ import { IPinningConfig } from '../grid.common';
1010import { SampleTestData } from '../../test-utils/sample-test-data.spec' ;
1111import { GridFunctions } from '../../test-utils/grid-functions.spec' ;
1212import { SortingDirection } from '../../data-operations/sorting-expression.interface' ;
13- import { IgxGridTransaction } from '../tree-grid/public_api' ;
14- import { IgxTransactionService } from '../../services/public_api' ;
1513import { GridSummaryFunctions } from '../../test-utils/grid-functions.spec' ;
1614import { IgxStringFilteringOperand } from '../../data-operations/filtering-condition' ;
1715import { IgxPaginatorComponent } from '../../paginator/paginator.component' ;
1816import { wait , UIInteractions } from '../../test-utils/ui-interactions.spec' ;
1917import { setupGridScrollDetection } from '../../test-utils/helper-utils.spec' ;
18+ import { GridRowConditionalStylingComponent } from '../../test-utils/grid-base-components.spec' ;
2019
2120describe ( 'Row Pinning #grid' , ( ) => {
2221 const FIXED_ROW_CONTAINER = '.igx-grid__tr--pinned ' ;
@@ -33,7 +32,8 @@ describe('Row Pinning #grid', () => {
3332 GridRowPinningWithMRLComponent ,
3433 GridRowPinningWithMDVComponent ,
3534 GridRowPinningWithTransactionsComponent ,
36- GridRowPinningWithInitialPinningComponent
35+ GridRowPinningWithInitialPinningComponent ,
36+ GridRowConditionalStylingComponent
3737 ] ,
3838 imports : [
3939 NoopAnimationsModule ,
@@ -1265,6 +1265,50 @@ describe('Row Pinning #grid', () => {
12651265 expect ( grid . hasPinnedRecords ) . toBeTrue ( ) ;
12661266 } ) ;
12671267 } ) ;
1268+
1269+ describe ( 'Conditional row styling' , ( ) => {
1270+
1271+ beforeEach ( fakeAsync ( ( ) => {
1272+ fix = TestBed . createComponent ( GridRowConditionalStylingComponent ) ;
1273+ fix . detectChanges ( ) ;
1274+ grid = fix . componentInstance . grid ;
1275+ tick ( ) ;
1276+ fix . detectChanges ( ) ;
1277+ } ) ) ;
1278+
1279+ it ( 'Shoud be able to conditionally style rows. Check is the class present in the row native element class list' , ( ) => {
1280+ fix . detectChanges ( ) ;
1281+ const firstRow = grid . gridAPI . get_row_by_index ( 0 ) ;
1282+ const fourthRow = grid . gridAPI . get_row_by_index ( 3 ) ;
1283+
1284+ expect ( firstRow ) . toBeDefined ( ) ;
1285+ expect ( firstRow . element . nativeElement . classList . contains ( 'eventRow' ) ) . toBeTrue ( ) ;
1286+ expect ( firstRow . element . nativeElement . classList . contains ( 'oddRow' ) ) . toBeFalse ( ) ;
1287+ expect ( fourthRow . element . nativeElement . classList . contains ( 'eventRow' ) ) . toBeFalse ( ) ;
1288+ expect ( fourthRow . element . nativeElement . classList . contains ( 'oddRow' ) ) . toBeTrue ( ) ;
1289+ } ) ;
1290+
1291+ it ( 'Should apply custom CSS bindings to the grid cells/rows. Check the style attribute to match each binding' , ( ) => {
1292+ const evenColStyles = {
1293+ background : ( row ) => row . index % 2 === 0 ? 'gray' : 'white' ,
1294+ animation : '0.75s popin'
1295+ } ;
1296+
1297+ fix . detectChanges ( ) ;
1298+ grid . rowStyles = evenColStyles ;
1299+ grid . notifyChanges ( true ) ;
1300+ fix . detectChanges ( ) ;
1301+ const firstRow = grid . gridAPI . get_row_by_index ( 0 ) ;
1302+ const fourthRow = grid . gridAPI . get_row_by_index ( 3 ) ;
1303+
1304+ const expectedEvenStyles = 'background: gray; animation: 0.75s ease 0s 1 normal none running popin;' ;
1305+ const expectedOddStyles = 'background: white; animation: 0.75s ease 0s 1 normal none running popin;' ;
1306+
1307+ expect ( firstRow . element . nativeElement . style . cssText ) . toEqual ( expectedEvenStyles ) ;
1308+ expect ( fourthRow . element . nativeElement . style . cssText ) . toEqual ( expectedOddStyles ) ;
1309+ } ) ;
1310+
1311+ } ) ;
12681312} ) ;
12691313
12701314@Component ( {
0 commit comments