Why is my datatable gone when I refresh my data after I have changed the language
Why is my datatable gone when I refresh my data after I have changed the language
frontendplace
Posts: 8Questions: 2Answers: 0
The situation: I have a datatable created with datatable="ng" and dt-options
<table id="ioRelationTable" datatable="ng" class="table hover" dt-options="vm.dtOptions" dt-column-defs="vm.dtColumnDefs">
<thead>
<tr>
<th>{{ "COL1" | translate }}</th>
<th>{{ "COL2" | translate }}</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="rel in vm.datalist">
<td>{{ rel.col1 }}</td>
<td>{{ rel.col2 }}</td>
</tr>
</tbody>
</table>
In the dt-options I have defined the language as a reference to a json file:
vm.dtOptions = DTOptionsBuilder
.newOptions()
.withDOM('<"pull-right l-ml-1"B>lftrip')
.withPaginationType('simple_numbers')
.withDisplayLength(25)
.withLanguageSource('i18n/dt_' + $rootScope.language.id + '.json')
.withButtons([
'csv',
'excel'
]);
vm.dtColumnDefs = [
DTColumnDefBuilder.newColumnDef(0),
DTColumnDefBuilder.newColumnDef(1).notSortable()
];
When I change the language in my rootscope the labels gets translated. But if I change the vm.datalist after this the whole table is gone. Why? When i dont use the datatable directive the table gets renderend
This discussion has been closed.
Answers
I suspect you might need to ask the Angular DataTables author - I'm afraid I'm no expert with Angular.
Allan
I have found one link with this same issue.
https://github.com/l-lin/angular-datatables/issues/476
And a pen already made by https://github.com/prakashnsm that shows the error when changing the data: http://codepen.io/prakashnsm/pen/vKNQWY