tigrang / cakephp-datatable

JQuery DataTable plugin server-side processing component for CakePHP
47 stars 29 forks source link

Localisation of column names #58

Closed agencefacton closed 9 years ago

agencefacton commented 9 years ago

Hello,

i have a problem if i want to traduce the column names with __() in my controller settings

public $components = [
    'DataTable.DataTable' => [
        'Badge' => [
            'columns' => [
                'id' => 'Réf',
                'num_serigraphe' => 'Numéro de sérigraphie',
                'num_serie' => 'Numéro de sérigraphie',
                'status' => 'Status',
                'created' => 'Créé le',
                'modified' => 'Modifié le',
                '' => null,
            ],
            'autoData' => false,
            //'autoRender' => false
        ],
    ],
];
tigrang commented 9 years ago

You can set it up in beforeFilter() method:

public function beforeFilter() {
    parent::beforeFilter();
    $this->DataTable->settings['Badge']['columns'] = [
        'id' => __('Id'),
        // ...
    ];
}
agencefacton commented 9 years ago

it works perfectly, thank you!