ajax-datatables-rails icon indicating copy to clipboard operation
ajax-datatables-rails copied to clipboard

Sort by different field of the object.

Open rahulthakur1390 opened this issue 3 years ago • 0 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.

rahulthakur1390 avatar Aug 30 '22 13:08 rahulthakur1390