File tree Expand file tree Collapse file tree 2 files changed +63
-3
lines changed
projects/igniteui-angular/src/lib/grids/common Expand file tree Collapse file tree 2 files changed +63
-3
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,9 @@ import {
1919 IgxColumnFormatterPipe ,
2020 IgxSummaryFormatterPipe ,
2121 IgxGridAddRowPipe ,
22- IgxHeaderGroupWidthPipe
22+ IgxHeaderGroupWidthPipe ,
23+ IgxGridRowClassesPipe ,
24+ IgxGridRowStylesPipe
2325} from './pipes' ;
2426
2527@NgModule ( {
@@ -42,7 +44,9 @@ import {
4244 IgxGridAddRowPipe ,
4345 IgxColumnFormatterPipe ,
4446 IgxSummaryFormatterPipe ,
45- IgxHeaderGroupWidthPipe
47+ IgxHeaderGroupWidthPipe ,
48+ IgxGridRowClassesPipe ,
49+ IgxGridRowStylesPipe
4650 ] ,
4751 exports : [
4852 IgxGridFilterConditionPipe ,
@@ -63,7 +67,9 @@ import {
6367 IgxGridAddRowPipe ,
6468 IgxColumnFormatterPipe ,
6569 IgxSummaryFormatterPipe ,
66- IgxHeaderGroupWidthPipe
70+ IgxHeaderGroupWidthPipe ,
71+ IgxGridRowClassesPipe ,
72+ IgxGridRowStylesPipe
6773 ] ,
6874 imports : [
6975 CommonModule
Original file line number Diff line number Diff line change @@ -63,6 +63,60 @@ export class IgxGridCellStylesPipe implements PipeTransform {
6363 }
6464}
6565
66+ /**
67+ * @hidden
68+ * @internal
69+ */
70+ @Pipe ( {
71+ name : 'igxGridRowClasses'
72+ } )
73+ export class IgxGridRowClassesPipe implements PipeTransform {
74+ constructor ( private gridAPI : GridBaseAPIService < IgxGridBaseDirective & GridType > ) { }
75+
76+ public transform ( cssClasses : { [ prop : string ] : any } , index : any , __ : number ) : string {
77+ if ( ! cssClasses ) {
78+ return '' ;
79+ }
80+ const result = [ ] ;
81+ for ( const cssClass of Object . keys ( cssClasses ) ) {
82+ const callbackOrValue = cssClasses [ cssClass ] ;
83+ const grid = ( this . gridAPI . grid as any ) ;
84+ const row = grid . getRowByIndex ( index ) ;
85+ const apply = typeof callbackOrValue === 'function' ? callbackOrValue ( row ) : callbackOrValue ;
86+ if ( apply ) {
87+ result . push ( cssClass ) ;
88+ }
89+ }
90+ return result . join ( ' ' ) ;
91+ }
92+ }
93+
94+ /**
95+ * @hidden
96+ * @internal
97+ */
98+ @Pipe ( {
99+ name : 'igxGridRowStyles'
100+ } )
101+ export class IgxGridRowStylesPipe implements PipeTransform {
102+
103+ constructor ( private gridAPI : GridBaseAPIService < IgxGridBaseDirective & GridType > ) { }
104+
105+ public transform ( styles : { [ prop : string ] : any } , index : number , __ : number ) : { [ prop : string ] : any } {
106+ const css = { } ;
107+ if ( ! styles ) {
108+ return css ;
109+ }
110+ const grid = ( this . gridAPI . grid as any ) ;
111+ for ( const prop of Object . keys ( styles ) ) {
112+ const cb = styles [ prop ] ;
113+ const row = grid . getRowByIndex ( index ) ;
114+ css [ prop ] = typeof cb === 'function' ? cb ( row ) : cb ;
115+ }
116+ return css ;
117+ }
118+ }
119+
66120/**
67121 * @hidden
68122 * @internal
You can’t perform that action at this time.
0 commit comments