jbox-web/ajax-datatables-rails

Sort by different field of the object.

rahulthakur1390 opened this issue · 1 comments

gem 'ajax-datatables-rails', '~> 1.2.0'

def view_columns
    @view_columns ||= {
      select: { source: 'Node.record_guid' },
      ip: { source: 'Node.ip' },
      dns: { source: 'Node.dns' },
      os: { source: 'Node.os' },
      domain: { source: 'Node.domain' },
      action: { source: 'Node.record_guid' }
    }
  end

  def initialize(params, opts = {})
    @view = opts[:view_context]
    super
  end

  def data
    records.map do |record|
      {
        select: datatable_check_box(record.record_guid, 'selected_nodes', "assessment_nodes #{@class_name}"),
        ip: record.ip,
        dns: record.dns,
        os: record.os,
        domain: record.domain,
        action: action_columns(record)
      }
    end
  end

I want to display ip column but when I sort ip column it should sort by ip_conversion field.
ip_conversion is an another field of the record object and ip_conversion is not displaying.
Is there any way to do this?

image

Thanks in advance. Please help me.

Got it the answer is given in the gem description so closed this.