Laravel-datatables: Unknown column 'DT_Row_Index' in 'order clause'

Created on 20 Sep 2018  ·  5Comments  ·  Source: yajra/laravel-datatables

Summary of problem or feature request

i add
->addIndexColumn()

in Controller,

in view I add

{ data: 'DT_Row_Index', name: 'DT_Row_Index' }

This error always appear :
Unknown column 'DT_Row_Index' in 'order clause'

question

Most helpful comment

It's added column and not part of the DB that's why it's not sortable. To fix, do:

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

All 5 comments

It's added column and not part of the DB that's why it's not sortable. To fix, do:

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

@yajra Thanks a lot yajra, is that impossible to sort that coloumn ?

Yes, I think it's impossible because index column is not part of the database / query. My usual guide is if it's doable on SQL level, the package should be able to handle it. Otherwise, it's not possible.

@yajra : ok I get it, btw thanks again for this great package,

how about adding notes for this one :
{ data: 'DT_Row_Index', name: 'DT_Row_Index' , orderable: false, searchable: false}

in : https://yajrabox.com/docs/laravel-datatables/master/index-column

Oh thanks, will add that when I got the chance. You can also PR if you can at https://github.com/yajra/laravel-datatables-docs/blob/master/index-column.md. Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ahmadbadpey picture ahmadbadpey  ·  3Comments

SGarridoDev picture SGarridoDev  ·  3Comments

techguydev picture techguydev  ·  3Comments

Mopster picture Mopster  ·  3Comments

josiahke picture josiahke  ·  3Comments