@@ -75,6 +75,10 @@ export class DataTableDirective implements OnDestroy, OnInit {
75
75
reject ( 'Both the table and dtOptions cannot be empty' ) ;
76
76
return ;
77
77
}
78
+
79
+ // Set a column unique
80
+ resolvedDTOptions . columns . forEach ( ( col : ADTColumns , i : number ) => col . id = i ) ;
81
+
78
82
// Using setTimeout as a "hack" to be "part" of NgZone
79
83
setTimeout ( ( ) => {
80
84
// Assign DT properties here
@@ -108,7 +112,7 @@ export class DataTableDirective implements OnDestroy, OnInit {
108
112
const pipe = el . ngPipeInstance ;
109
113
const pipeArgs = el . ngPipeArgs || [ ] ;
110
114
// 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 ) ;
112
116
// get <td> element which holds data using index
113
117
const rowFromCol = row . childNodes . item ( i ) ;
114
118
// Transform data with Pipe and PipeArgs
@@ -125,7 +129,7 @@ export class DataTableDirective implements OnDestroy, OnInit {
125
129
colsWithTemplate . forEach ( el => {
126
130
const { ref, context } = el . ngTemplateRef ;
127
131
// 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 ) ;
129
133
const cellFromIndex = row . childNodes . item ( i ) ;
130
134
// reset cell before applying transform
131
135
$ ( cellFromIndex ) . html ( '' ) ;
0 commit comments