We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Taking same city example:
How to proceed if I want to sort by "full_name"?
City model :
` class City < ApplicationRecord belongs_to :country
def full_name name + ' city' end end `
city_datatable.rb :
` def view_columns @view_columns ||= { check_box: { source: 'City.id', orderable: false, searchable: false }, name: { source: 'City.name' }, iata: { source: 'City.iata' }, country_name: { source: 'City.country_id', cond: filter_country_condition }, full_name: { source: 'City.full_name', searchable: false } } end
def data records.map do |record| { check_box: record.decorate.to_checkbox(selected: selected.include?(record.id)), name: record.name, iata: record.iata, country_name: record.country.try(:name), full_name: record.full_name } end end `
Haml file changes.
`
ERROR :
` Completed 500 Internal Server Error in 9ms (ActiveRecord: 1.0ms | Allocations: 2457)
ActiveRecord::StatementInvalid (SQLite3::SQLException: no such column: cities.full_name):
app/datatables/city_datatable.rb:15:in map' app/datatables/city_datatable.rb:15:in data' app/controllers/cities_controller.rb:15:in block (2 levels) in datatable' app/controllers/cities_controller.rb:14:in datatable' `
map' app/datatables/city_datatable.rb:15:in
block (2 levels) in datatable' app/controllers/cities_controller.rb:14:in
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Taking same city example:
How to proceed if I want to sort by "full_name"?
City model :
`
class City < ApplicationRecord
belongs_to :country
def full_name
name + ' city'
end
end
`
city_datatable.rb :
`
def view_columns
@view_columns ||= {
check_box: { source: 'City.id', orderable: false, searchable: false },
name: { source: 'City.name' },
iata: { source: 'City.iata' },
country_name: { source: 'City.country_id', cond: filter_country_condition },
full_name: { source: 'City.full_name', searchable: false }
}
end
def data
records.map do |record|
{
check_box: record.decorate.to_checkbox(selected: selected.include?(record.id)),
name: record.name,
iata: record.iata,
country_name: record.country.try(:name),
full_name: record.full_name
}
end
end
`
Haml file changes.
`
`
ERROR :
`
Completed 500 Internal Server Error in 9ms (ActiveRecord: 1.0ms | Allocations: 2457)
ActiveRecord::StatementInvalid (SQLite3::SQLException: no such column: cities.full_name):
app/datatables/city_datatable.rb:15:in
map' app/datatables/city_datatable.rb:15:in
data'app/controllers/cities_controller.rb:15:in
block (2 levels) in datatable' app/controllers/cities_controller.rb:14:in
datatable'`
The text was updated successfully, but these errors were encountered: