@@ -75,6 +75,10 @@ export class DataTableDirective implements OnDestroy, OnInit {
7575 reject ( 'Both the table and dtOptions cannot be empty' ) ;
7676 return ;
7777 }
78+
79+ // Set a column unique
80+ resolvedDTOptions . columns . forEach ( ( col : ADTColumns , i : number ) => col . id = i ) ;
81+
7882 // Using setTimeout as a "hack" to be "part" of NgZone
7983 setTimeout ( ( ) => {
8084 // Assign DT properties here
@@ -108,7 +112,7 @@ export class DataTableDirective implements OnDestroy, OnInit {
108112 const pipe = el . ngPipeInstance ;
109113 const pipeArgs = el . ngPipeArgs || [ ] ;
110114 // find index of column using `data` attr
111- const i = columns . filter ( c => c . visible !== false ) . findIndex ( e => e . data === el . data ) ;
115+ const i = columns . filter ( c => c . visible !== false ) . findIndex ( e => e . id === el . id ) ;
112116 // get <td> element which holds data using index
113117 const rowFromCol = row . childNodes . item ( i ) ;
114118 // Transform data with Pipe and PipeArgs
@@ -125,7 +129,7 @@ export class DataTableDirective implements OnDestroy, OnInit {
125129 colsWithTemplate . forEach ( el => {
126130 const { ref, context } = el . ngTemplateRef ;
127131 // get <td> element which holds data using index
128- const i = columns . filter ( c => c . visible !== false ) . findIndex ( e => e . data === el . data ) ;
132+ const i = columns . filter ( c => c . visible !== false ) . findIndex ( e => e . id === el . id ) ;
129133 const cellFromIndex = row . childNodes . item ( i ) ;
130134 // reset cell before applying transform
131135 $ ( cellFromIndex ) . html ( '' ) ;
0 commit comments