InvalidSearchColumn error when using column defined as data: null
diesl opened this issue · 2 comments
I have some table columns that are not linked to a database column. These columns are used for example to display an input field, some static text, etc. I use the null type of columns.data
Example:
columnDefs: [
{
targets: 'css-class'
data: null
defaultContent: 'foobar'
searchable: false
orderable: false
},
...
]This is working with ajax-datatables-rails 1.2.0, but with newer versions I get a validation error:
Unknown column. Check that
datafield is filled on JS side with the column name
I am not sure how to "fix" this error. Can you point me to the right direction to make it work again?
EDIT:
Not sure why, but somehow I missed the closed issues about this topic:
However, I do not think your proposed "fix" to map a virtual column to some existing model attribute is a solution. On the contrary, it feels like a workaround for an problem that was introduced without need.
Additionally I want to add that this is another breaking change (next to #383) that was introduced in a minor release. I propose to revert this change and release a new minor version 1.4.0.
I am not sure how to "fix" this error. Can you point me to the right direction to make it work again?
Compare the columns declared in the view with the ones declared in your datatable class : it seems that one column is not declared in your view.
that are not linked to a database column.
also if these table columns are not linked to a database column obviously they cannot be searchable neither orderable... so IMHO this make totally sense :
def view_columns
@view_columns ||= {
...
:'12' => { searchable: false, orderable: false }
}
end