Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Translate Ui-grid Angular

I'm trying to translate Ui-grid in angular but i can't . i just want to translate columnDefs .
here is my controller :

 $scope.gridOptions = {

        enableSorting: true,
        columnDefs: [

                  { name: 'نمایش', cellClass: "editCell", cellTemplate: '<i id="editBtn" tooltip-placement="left" tooltip="نمایش درخواست" class="fa fa-eye" ng-click="getExternalScopes().editUser(row.entity.RequestCode)" ></i>', headerClass: 'JobHeader' },

                   {
                       name: 'کد شهر',  headerClass: 'cityHeader', field: 'CityCode', editableCellTemplate: self.editableCellTempate, 
                       enableCellEdit: true
                   },
                    { name: 'کد امور', field: 'RgnCode' },
        { name: 'شماره درخواست', field: 'RequestCode' },

        ],


    };   

i want to translate name in columnDefs

Any idea ?

like image 554
Sadeghbayan Avatar asked Dec 11 '22 00:12

Sadeghbayan


2 Answers

Use

  • cellFilter:'translate' for cell,
  • headerCellFilter:'translate' for header
  • footerCellFilter: 'translate' for footer

in colummDefs

like image 169
YOU Avatar answered Dec 30 '22 21:12

YOU


I used {field:'id', displayName:'ID_TRANSLATION_KEY', headerFilter:'translate'}. It works like usual template translation. Only problem with your solution you may be losing default sorting functionality offered by the component (have to create your own) when you use headerCellTemplate. I think this may help someone.

like image 34
ddsultan Avatar answered Dec 30 '22 20:12

ddsultan