Sha256: 07253ef7c2365b34bff135988c7aa18e78f918a8163b55a187e877d497c7b8cf

Contents?: true

Size: 423 Bytes

Versions: 2

Compression:

Stored size: 423 Bytes

Contents

# frozen_string_literal: true

class DatatableCustomColumn < ComplexDatatable
  def view_columns
    super.deep_merge(full_name: { cond: filter_full_name })
  end

  def get_raw_records
    User.select("*, CONCAT(first_name, ' ', last_name) as full_name")
  end

  private

  def filter_full_name
    ->(_column, value) { ::Arel::Nodes::SqlLiteral.new("CONCAT(first_name, ' ', last_name)").matches("#{value}%") }
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ajax-datatables-rails-1.5.0 spec/support/datatables/datatable_custom_column.rb
ajax-datatables-rails-1.4.0 spec/support/datatables/datatable_custom_column.rb