Laravel-datatables: How translate render in View using Datatable Service?

Created on 16 May 2016  ·  3Comments  ·  Source: yajra/laravel-datatables

Hi, I using this great package, when implement service render in te view with this line and Work fine.

{!! $dataTable->table([ 'id' => 'datatable', 'class' => 'table table-bordered]) !!}

But I want add more options like this javascript (not using service example)

<script>
$(function() {
     $('#data-table').DataTable({
        processing: true,
        serverSide: true,
        paging: true,
     ],
        ajax: '{!! route('ventas.data') !!}',
        order: [ [0, 'desc'] ],
        columns: [
            {data: 'id',"searchable":false, name: 'id'},
            {data: 'name', name: 'name'},
            {data: 'actions', "orderable": false, "searchable":false, visible: true, name: 'actions'},
        ],
            "language": {
                "url": "//cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/Spanish.json"
            }
    });
});
</script>       

For example languague to Spanish. I know adding this line via javascript works.
"language": {
"url": "//cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/Spanish.json"
}
But how and where add this lines options using Service Implementation?

  • Operating System Win7 Xampp 3.2.1
  • PHP Version 5.6
  • Laravel Version 5.2
  • Laravel-Datatables Version 6
question

Most helpful comment

Thanks Yajra idol !! work fine in this way:
'language' => ['url' => '//cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/Spanish.json']

All 3 comments

I tried pass parameter on this way, but not work

  public function html()
    {
        return $this->builder()
            ->columns([
                'id',
                'name',
                'actions',
            ])
            ->parameters([
                'dom' => 'Bfrtip',
                'order' => [ [0, 'desc'] ],
                'buttons' => ['csv', 'excel'],
                'language' => '"url: //cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/Spanish.json"'
            ]);
    }

Any idea please...

I think you need to use array on the language param like:

  public function html()
    {
        return $this->builder()
            ->columns([
                'id',
                'name',
                'actions',
            ])
            ->parameters([
                'dom' => 'Bfrtip',
                'order' => [ [0, 'desc'] ],
                'buttons' => ['csv', 'excel'],
                'language' => ['url => '//cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/Spanish.json']
            ]);
    }

Thanks Yajra idol !! work fine in this way:
'language' => ['url' => '//cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/Spanish.json']

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hohuuhau picture hohuuhau  ·  3Comments

shadoWalker89 picture shadoWalker89  ·  3Comments

ghost picture ghost  ·  3Comments

SGarridoDev picture SGarridoDev  ·  3Comments

vipin733 picture vipin733  ·  3Comments