Laravel-datatables: How do I add auto incrementing row to the table.

Created on 4 Aug 2016  路  9Comments  路  Source: yajra/laravel-datatables

I want to display index as number in increasing order.

question

Most helpful comment

@mansouralex by default, the data key used is DT_Row_Index:

{data: 'DT_Row_Index', orderable: false, searchable: false}

All 9 comments

Do you mean the internal index id? Maybe try using this PR as ref: https://github.com/yajra/laravel-datatables/pull/597

return $this->datatables
            ->collection($this->query())
            ->addIndexColumn()
            ->make(true);

I was indeed looking for addIndexColumn

Thank you for the quick reply,

@yajra At the JS side how we should add the new index column ?

@mansouralex by default, the data key used is DT_Row_Index:

{data: 'DT_Row_Index', orderable: false, searchable: false}

@yajra sir how can i order the indexcolumn to descending order, (3,2,1)

Thanks

I have still this error:
DataTables warning: table id=daily_schedule - Requested unknown parameter 'DT_Row_Index' for row 0, column 0. For more information about this error, please see http://datatables.net/tn/4

@yajra

@javidjan sorry for the inconvenience. DT_Row_Index was renamed to DT_RowIndex.

See https://github.com/yajra/laravel-datatables/pull/1882 for ref.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

techguydev picture techguydev  路  3Comments

alejandri picture alejandri  路  3Comments

SGarridoDev picture SGarridoDev  路  3Comments

ghost picture ghost  路  3Comments

kamrava picture kamrava  路  3Comments