@@ -25,23 +25,21 @@ export class IgxTreeGridHierarchizingPipe implements PipeTransform {
25
25
}
26
26
27
27
public transform ( collection : any [ ] , primaryKey : string , foreignKey : string , childDataKey : string ,
28
- id : string , pinned : boolean = false , pipeTrigger : number ) : ITreeGridRecord [ ] {
28
+ id : string , pipeTrigger : number ) : ITreeGridRecord [ ] {
29
29
const grid = this . gridAPI . grid ;
30
30
let hierarchicalRecords : ITreeGridRecord [ ] = [ ] ;
31
31
const treeGridRecordsMap = new Map < any , ITreeGridRecord > ( ) ;
32
32
const flatData : any [ ] = [ ] ;
33
33
34
- if ( pinned ) {
35
- hierarchicalRecords = this . normalizePinnedRecords ( collection , primaryKey ) ;
36
- } else if ( primaryKey && foreignKey ) {
34
+ if ( primaryKey && foreignKey ) {
37
35
hierarchicalRecords = this . hierarchizeFlatData ( id , collection , primaryKey , foreignKey , treeGridRecordsMap , flatData ) ;
38
36
} else if ( childDataKey ) {
39
37
hierarchicalRecords = this . hierarchizeRecursive ( id , collection , primaryKey , childDataKey , undefined ,
40
38
flatData , 0 , treeGridRecordsMap ) ;
41
39
}
42
40
43
41
grid . flatData = flatData ;
44
- grid . records = ( pinned ) ? grid . records : treeGridRecordsMap ;
42
+ grid . records = treeGridRecordsMap ;
45
43
grid . rootRecords = hierarchicalRecords ;
46
44
return hierarchicalRecords ;
47
45
}
@@ -123,19 +121,6 @@ export class IgxTreeGridHierarchizingPipe implements PipeTransform {
123
121
124
122
return result ;
125
123
}
126
-
127
- private normalizePinnedRecords ( collection : any [ ] , primaryKey : string ) {
128
- const result : ITreeGridRecord [ ] = [ ] ;
129
- collection . forEach ( row => {
130
- const record : ITreeGridRecord = {
131
- rowID : this . getRowID ( primaryKey , row ) ,
132
- data : row ,
133
- children : [ ]
134
- } ;
135
- result . push ( record ) ;
136
- } ) ;
137
- return result ;
138
- }
139
124
}
140
125
141
126
/**
@@ -342,13 +327,32 @@ export class IgxTreeGridRowPinningPipe implements PipeTransform {
342
327
return [ ] ;
343
328
}
344
329
345
- const result = grid . flatData . filter ( ( value , index ) => grid . isRecordPinned ( value ) ) ;
330
+ let result = grid . flatData . filter ( ( value , index ) => grid . isRecordPinned ( value ) ) ;
346
331
347
332
// pinned records should be ordered as they were pinned.
348
333
result . sort ( ( rec1 , rec2 ) => grid . pinRecordIndex ( rec1 ) - grid . pinRecordIndex ( rec2 ) ) ;
349
334
335
+ result = this . normalizePinnedRecords ( result , this . gridAPI . grid . primaryKey ) ;
336
+
350
337
return result ;
351
338
}
339
+
340
+ private normalizePinnedRecords ( collection : any [ ] , primaryKey : string ) {
341
+ const result : ITreeGridRecord [ ] = [ ] ;
342
+ collection . forEach ( row => {
343
+ const record : ITreeGridRecord = {
344
+ rowID : this . getRowID ( primaryKey , row ) ,
345
+ data : row ,
346
+ children : [ ]
347
+ } ;
348
+ result . push ( record ) ;
349
+ } ) ;
350
+ return result ;
351
+ }
352
+
353
+ private getRowID ( primaryKey : any , rowData : any ) {
354
+ return primaryKey ? rowData [ primaryKey ] : rowData ;
355
+ }
352
356
}
353
357
354
358
@Pipe ( {
0 commit comments