Add row number column to jquery datatables

前端 未结 4 2173
心在旅途
心在旅途 2020-12-08 01:21

I want jQuery datatables to automatically create row number column in the first column like datagrid in VB.

It looks like this:

4条回答
  •  暖寄归人
    2020-12-08 01:52

    You just define an empty column in aoColumns.

    Then in fnRowCallback function you just edit the column how you like. This callback is run every time new row is created.

    Basicly if your first column has the row number, you could just do this in fnRowCallback:

    var index = iDisplayIndex +1;
    $('td:eq(0)',nRow).html(index);
    return nRow;
    

提交回复
热议问题