ajax-datatables-rails icon indicating copy to clipboard operation
ajax-datatables-rails copied to clipboard

how to implement datatables index column ?

Open buncis opened this issue 8 years ago • 0 comments
trafficstars

I'm tring to implement index column, If we see the example https://datatables.net/examples/api/counter_columns.html we just need to throw empty

and add this line
$(document).ready(function() {
    var t = $('#example').DataTable( {
        "columnDefs": [ {
            "searchable": false,
            "orderable": false,
            "targets": 0
        } ],
        "order": [[ 1, 'asc' ]]
    } );
 
    t.on( 'order.dt search.dt', function () {
        t.column(0, {search:'applied', order:'applied'}).nodes().each( function (cell, i) {
            cell.innerHTML = i+1;
        } );
    } ).draw();
} );

so I'm trying to throw null data from the server but it fails, since the counter is only count the data that send to html(only 10/based on show entries)

then I conclude the best way is to send the index column from the server itself instead calculate it in front end

@n-rodriguez any idea how to implement this?, I think its more easy to implements now, since we no longer depends on pagination gem

#64 related

buncis avatar Oct 10 '17 06:10 buncis