@@ -30,7 +30,7 @@ describe('Row Pinning #grid', () => {
30
30
IgxGridModule
31
31
]
32
32
} )
33
- . compileComponents ( ) ;
33
+ . compileComponents ( ) ;
34
34
} ) ) ;
35
35
36
36
describe ( '' , ( ) => {
@@ -71,7 +71,7 @@ describe('Row Pinning #grid', () => {
71
71
72
72
// 2 records pinned + 2px border
73
73
expect ( grid . pinnedRowHeight ) . toBe ( 2 * grid . renderedRowHeight + 2 ) ;
74
- const expectedHeight = parseInt ( grid . height , 10 ) - grid . pinnedRowHeight - 18 - grid . theadRow . nativeElement . offsetHeight ;
74
+ const expectedHeight = parseInt ( grid . height , 10 ) - grid . pinnedRowHeight - 18 - grid . theadRow . nativeElement . offsetHeight ;
75
75
expect ( grid . calcHeight - expectedHeight ) . toBeLessThanOrEqual ( 1 ) ;
76
76
} ) ;
77
77
@@ -110,7 +110,7 @@ describe('Row Pinning #grid', () => {
110
110
111
111
// 2 records pinned + 2px border
112
112
expect ( grid . pinnedRowHeight ) . toBe ( 2 * grid . renderedRowHeight + 2 ) ;
113
- const expectedHeight = parseInt ( grid . height , 10 ) - grid . pinnedRowHeight - 18 - grid . theadRow . nativeElement . offsetHeight ;
113
+ const expectedHeight = parseInt ( grid . height , 10 ) - grid . pinnedRowHeight - 18 - grid . theadRow . nativeElement . offsetHeight ;
114
114
expect ( grid . calcHeight - expectedHeight ) . toBeLessThanOrEqual ( 1 ) ;
115
115
} ) ;
116
116
@@ -195,31 +195,63 @@ describe('Row Pinning #grid', () => {
195
195
} ) ;
196
196
197
197
it ( 'should pin/unpin via row pinned setter.' , ( ) => {
198
- // pin 2nd row
199
- let row = grid . getRowByIndex ( 1 ) ;
200
- row . pinned = true ;
201
- fix . detectChanges ( ) ;
202
-
203
- expect ( grid . pinnedRows . length ) . toBe ( 1 ) ;
204
- let pinRowContainer = fix . debugElement . queryAll ( By . css ( FIXED_ROW_CONTAINER ) ) ;
205
- expect ( pinRowContainer . length ) . toBe ( 1 ) ;
206
- expect ( pinRowContainer [ 0 ] . children . length ) . toBe ( 1 ) ;
207
- expect ( pinRowContainer [ 0 ] . children [ 0 ] . context . rowID ) . toBe ( fix . componentInstance . data [ 1 ] ) ;
208
-
209
- expect ( grid . getRowByIndex ( 0 ) . rowID ) . toBe ( fix . componentInstance . data [ 1 ] ) ;
210
- expect ( grid . getRowByIndex ( 1 ) . rowID ) . toBe ( fix . componentInstance . data [ 0 ] ) ;
211
-
212
- // unpin
213
- row = grid . getRowByIndex ( 0 ) ;
214
- row . pinned = false ;
215
- fix . detectChanges ( ) ;
216
-
217
- expect ( grid . pinnedRows . length ) . toBe ( 0 ) ;
218
- pinRowContainer = fix . debugElement . queryAll ( By . css ( FIXED_ROW_CONTAINER ) ) ;
219
- expect ( pinRowContainer . length ) . toBe ( 0 ) ;
220
-
221
- expect ( grid . getRowByIndex ( 0 ) . rowID ) . toBe ( fix . componentInstance . data [ 0 ] ) ;
222
- expect ( grid . getRowByIndex ( 1 ) . rowID ) . toBe ( fix . componentInstance . data [ 1 ] ) ;
198
+ // pin 2nd row
199
+ let row = grid . getRowByIndex ( 1 ) ;
200
+ row . pinned = true ;
201
+ fix . detectChanges ( ) ;
202
+
203
+ expect ( grid . pinnedRows . length ) . toBe ( 1 ) ;
204
+ let pinRowContainer = fix . debugElement . queryAll ( By . css ( FIXED_ROW_CONTAINER ) ) ;
205
+ expect ( pinRowContainer . length ) . toBe ( 1 ) ;
206
+ expect ( pinRowContainer [ 0 ] . children . length ) . toBe ( 1 ) ;
207
+ expect ( pinRowContainer [ 0 ] . children [ 0 ] . context . rowID ) . toBe ( fix . componentInstance . data [ 1 ] ) ;
208
+
209
+ expect ( grid . getRowByIndex ( 0 ) . rowID ) . toBe ( fix . componentInstance . data [ 1 ] ) ;
210
+ expect ( grid . getRowByIndex ( 1 ) . rowID ) . toBe ( fix . componentInstance . data [ 0 ] ) ;
211
+
212
+ // unpin
213
+ row = grid . getRowByIndex ( 0 ) ;
214
+ row . pinned = false ;
215
+ fix . detectChanges ( ) ;
216
+
217
+ expect ( grid . pinnedRows . length ) . toBe ( 0 ) ;
218
+ pinRowContainer = fix . debugElement . queryAll ( By . css ( FIXED_ROW_CONTAINER ) ) ;
219
+ expect ( pinRowContainer . length ) . toBe ( 0 ) ;
220
+
221
+ expect ( grid . getRowByIndex ( 0 ) . rowID ) . toBe ( fix . componentInstance . data [ 0 ] ) ;
222
+ expect ( grid . getRowByIndex ( 1 ) . rowID ) . toBe ( fix . componentInstance . data [ 1 ] ) ;
223
+ } ) ;
224
+
225
+ it ( 'should pin rows when columns are grouped.' , ( ) => {
226
+ // pin 1st and 2nd data row
227
+ grid . pinRow ( fix . componentInstance . data [ 0 ] ) ;
228
+ grid . pinRow ( fix . componentInstance . data [ 1 ] ) ;
229
+ fix . detectChanges ( ) ;
230
+
231
+ // group by string column
232
+ grid . groupBy ( {
233
+ fieldName : 'ContactTitle' , dir : SortingDirection . Desc , ignoreCase : false
234
+ } ) ;
235
+ fix . detectChanges ( ) ;
236
+
237
+ expect ( grid . pinnedRows . length ) . toBe ( 2 ) ;
238
+
239
+ // verify rows
240
+ const groupRows = grid . groupsRowList . toArray ( ) ;
241
+ const dataRows = grid . dataRowList . toArray ( ) ;
242
+
243
+ expect ( groupRows . length ) . toEqual ( 2 ) ;
244
+ expect ( dataRows . length ) . toEqual ( 7 ) ;
245
+ expect ( groupRows [ 0 ] . groupRow . records [ 0 ] . ID ) . toEqual ( 'AROUT' ) ;
246
+
247
+ // pin 4th data row with ID:AROUT
248
+ grid . pinRow ( fix . componentInstance . data [ 3 ] ) ;
249
+ fix . detectChanges ( ) ;
250
+
251
+ expect ( grid . pinnedRows . length ) . toBe ( 3 ) ;
252
+
253
+ // make sure the pinned row is out of the first groupBy group
254
+ expect ( groupRows [ 0 ] . groupRow . records [ 0 ] . ID ) . toEqual ( 'BLAUS' ) ;
223
255
} ) ;
224
256
225
257
it ( 'should page through unpinned collection with modified pageSize = pageSize - pinnedRows.lenght.' , ( ) => {
@@ -308,7 +340,7 @@ describe('Row Pinning #grid', () => {
308
340
309
341
it ( 'should allow pinning added row.' , ( ) => {
310
342
311
- grid . addRow ( { 'ID' : 'Test' , 'CompanyName' : 'Test' } ) ;
343
+ grid . addRow ( { 'ID' : 'Test' , 'CompanyName' : 'Test' } ) ;
312
344
fix . detectChanges ( ) ;
313
345
314
346
grid . pinRow ( 'Test' ) ;
0 commit comments