Column index in datatables laravel

0

When I did not load the data dynamically into the table I used this way to create the index column: link

p>
 t.on( 'order.dt search.dt', function () {
    t.column(0, {search:'applied', order:'applied'}).nodes().each( function (cell, i) {
        cell.innerHTML = i+1;
    } );
} ).draw();

Example: link

However, now that I'm loading the table dynamically server-side does not work properly. It is always from 1 to 5. If you increase results per page add the index.

I tried to use it that way and I was not successful either:

t.on( 'order.dt search.dt', function () {
t.column(0, {search:'applied', order:'applied'}).nodes().each( function (cell, i) {
    cell.innerHTML = i+1;
    t.cell(cell).invalidate('dom');
} ); } ).draw();

I am studying jquery, laravel and server-side datatables use yet. I do not know how to solve this.

    
asked by anonymous 23.08.2017 / 18:26

1 answer

0

Get it to work.

For those who go through the same problem that I solved using page.info (), making the product the value of the number of items to be displayed and the current page number: page.info () page * page.info (). length .

tabela.on('draw.dt', function() {
    tabela.column(0, { search: 'applied', order: 'applied'}).nodes().each(function(cell, i) {
        cell.innerHTML = tabela.page.info().page * tabela.page.info().length + i + 1;  
    });
}).draw();
    
24.08.2017 / 04:01