Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InvalidSearchColumn error when using column defined as data: null #399

Open
diesl opened this issue Oct 15, 2021 · 2 comments
Open

InvalidSearchColumn error when using column defined as data: null #399

diesl opened this issue Oct 15, 2021 · 2 comments

Comments

@diesl
Copy link

diesl commented Oct 15, 2021

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 data field 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.

@n-rodriguez
Copy link
Member

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.

@n-rodriguez
Copy link
Member

n-rodriguez commented Feb 23, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants