ui-grid: Problem translating field displayName values in ng-grid

I have a multilingual application that is using the pascalprecht.translate module (https://github.com/PascalPrecht/angular-translate) to translate all fixed data (labels etc) in my application. The only thing that is not translating are the field displayName values of my ng-grid. This is currently my config (without the translations for the headers):

  $scope.projectsGridOptions = {
      data: 'projectDataList',
      columnDefs: [
      { field: 'name', displayName: 'Name' },
      { field: 'description', displayName: 'Description' },
      { field: 'internal', displayName: 'Internal' },
      { field: 'client.name', displayName: 'ClientName'},
      { field: '', cellTemplate: '<a class="btn btn-success" data-ng-href="#/projects/detail/{{row.entity.id}}">{{"VIEW" | translate}}</a> <a class="btn btn-alert" data-ng-href="#/projects/update/{{row.entity.id}}">{{"EDIT" | translate}}</a> <button class="btn btn-danger" data-ng-click="delete(13)">{{"DELETE" | translate}}</a>' },

      ],
      enableRowReordering: true,
      enableRowSelection: false,
      showFilter: true,
      filterOptions: {
          filterText: "",
          useExternalFilter: false
      },
  };

What I would like to do is this:

$scope.projectsGridOptions = { data: ‘projectDataList’, columnDefs: [ { field: ‘name’, displayName: ‘{{“NAME”|translate}}’ }, { field: ‘description’, displayName: ‘{{“DESCRIPTION”|translate}}’ }, { field: ‘internal’, displayName: ‘{{“INTERNAL”|translate}}’ }, { field: ‘client.name’, displayName: ‘{{“CLIENTNAME”|translate}}’}, { field: ‘’, cellTemplate: ‘{{“VIEW” | translate}} {{“EDIT” | translate}} <button class="btn btn-danger" data-ng-click="delete(13)">{{“DELETE” | translate}}’ },

      ],
      enableRowReordering: true,
      enableRowSelection: false,
      showFilter: true,
      filterOptions: {
          filterText: "",
          useExternalFilter: false
      },
  };

but unfortunately this only renders the text {{“NAME”|translate}} in the column header. Any idea how this would be possible?

About this issue

  • Original URL
  • State: closed
  • Created 11 years ago
  • Comments: 15 (5 by maintainers)

Most upvoted comments

Here is a plunker: http://plnkr.co/edit/KnrKTst5dWXvlZNeIy9c?p=preview

I wanted to put it into the i18n tutorial, but haven’t worked out how to include external scripts - I’ll try again later.

{field:'name', headerCellTemplate:'< div >{{"NAME"|translate}}</ div >'}