Skip to content
This repository was archived by the owner on Feb 2, 2025. It is now read-only.

Title disappears after changing datatable language #638

Closed
vincentf06 opened this issue Feb 25, 2016 · 3 comments
Closed

Title disappears after changing datatable language #638

vincentf06 opened this issue Feb 25, 2016 · 3 comments

Comments

@vincentf06
Copy link

I'm using angular translate, reading language from json files, according to #351 I have to define column titles in the view. But in this case column titles will disappear if I switch datatable language(dtOptions.language.url). TH element is still there, however no text node inside.

update:
title will appear again if running $route.reload()

html:

            <table class="data-table" datatable="" dt-options="dtOptions" dt-columns="dtColumns" dt-instance="dtInstance">
                <thead>
                    <tr>
                        <th>{{"datatable.type" | translate}}</th>
                        <th>{{"datatable.name" | translate}}</th>
                    </tr>
                </thead>
            </table>

columns:

        $scope.dtColumns = [
            {
              'mData': null,
              'mRender': function(data, type, full, meta) {
                if (data.type == 'folder') {
                  return '<a class="folder" ng-click="getFolderContent(\'' + data.name + '\'); $event.stopPropagation()">' +
                    '</a>' 
                } else {
                return '<a class="image">' +
                    '</a>'
                } 
              }
            },
            {'mData': 'name'},     
        ];

globally change language in parent controller:

        $scope.changeLng = function(lng){
            $translate.use(lng);
            $scope.$broadcast('changelanguage', lng)
        };

change datatable language in child controller:

        $scope.$on('changelanguage', function(event, lng){
          $scope.dtOptions.language.url = '../locales/dt/'+lng+'.json';
          $scope.dtInstance.rerender();
        })

text node disappears

<th class="sorting_asc" tabindex="0" aria-controls="DataTables_Table_0" rowspan="1" colspan="1" aria-sort="ascending" aria-label=": activate to sort column descending" style="width: 226px;"></th>
@vincentf06 vincentf06 changed the title Title disappears when changing datatable language Title disappears after changing datatable language Feb 26, 2016
@l-lin
Copy link
Owner

l-lin commented Mar 7, 2016

Can you put it on a plnkr or something alike? I can't really understand your issue.

@OlympicLarry
Copy link

how about:
$scope.dtOptions = $scope.dtOptions.withLanguageSource('../locales/dt/'+lng+'.json');

@vincentf06
Copy link
Author

Yes I've tried that, it's still not working. I'll reproduce the issue latter on

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants