@@ -25,23 +25,21 @@ export class IgxTreeGridHierarchizingPipe implements PipeTransform {
2525 }
2626
2727 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 [ ] {
2929 const grid = this . gridAPI . grid ;
3030 let hierarchicalRecords : ITreeGridRecord [ ] = [ ] ;
3131 const treeGridRecordsMap = new Map < any , ITreeGridRecord > ( ) ;
3232 const flatData : any [ ] = [ ] ;
3333
34- if ( pinned ) {
35- hierarchicalRecords = this . normalizePinnedRecords ( collection , primaryKey ) ;
36- } else if ( primaryKey && foreignKey ) {
34+ if ( primaryKey && foreignKey ) {
3735 hierarchicalRecords = this . hierarchizeFlatData ( id , collection , primaryKey , foreignKey , treeGridRecordsMap , flatData ) ;
3836 } else if ( childDataKey ) {
3937 hierarchicalRecords = this . hierarchizeRecursive ( id , collection , primaryKey , childDataKey , undefined ,
4038 flatData , 0 , treeGridRecordsMap ) ;
4139 }
4240
4341 grid . flatData = flatData ;
44- grid . records = ( pinned ) ? grid . records : treeGridRecordsMap ;
42+ grid . records = treeGridRecordsMap ;
4543 grid . rootRecords = hierarchicalRecords ;
4644 return hierarchicalRecords ;
4745 }
@@ -123,19 +121,6 @@ export class IgxTreeGridHierarchizingPipe implements PipeTransform {
123121
124122 return result ;
125123 }
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- }
139124}
140125
141126/**
@@ -342,13 +327,32 @@ export class IgxTreeGridRowPinningPipe implements PipeTransform {
342327 return [ ] ;
343328 }
344329
345- const result = grid . flatData . filter ( ( value , index ) => grid . isRecordPinned ( value ) ) ;
330+ let result = grid . flatData . filter ( ( value , index ) => grid . isRecordPinned ( value ) ) ;
346331
347332 // pinned records should be ordered as they were pinned.
348333 result . sort ( ( rec1 , rec2 ) => grid . pinRecordIndex ( rec1 ) - grid . pinRecordIndex ( rec2 ) ) ;
349334
335+ result = this . normalizePinnedRecords ( result , this . gridAPI . grid . primaryKey ) ;
336+
350337 return result ;
351338 }
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+ }
352356}
353357
354358@Pipe ( {
0 commit comments