Skip to content

how to implement datatables index column ? #259

Open
@buncis

Description

@buncis

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions