ruby中的数据表排序计算列

时间:2013-12-19 20:51:09

标签: jquery ruby sorting datatable

我从计算值中对列进行排序时遇到问题。 这是问题所在:

我的数据:

def data
    vendors.map do |vendor|
      [
        vendor.image? ? "<img src='#{vendor.image.timeline_thumb.url}' >" : "NO IMAGE" ,
        vendor.name,
        vendor.orders_in_month(Time.zone.today).count,
        count1 = vendor.meals_in_month(Time.zone.today),
        count2 = vendor.meals_in_month(Time.zone.today-1.month),
        count3 = vendor.meals_in_month(Time.zone.today-2.month),
        count1+count2+count3
      ]
    end
  end

我想用count1对列进行排序 所以我写了这个:

def sort_column
    columns = [
      nil,
      "display_name", 
      nil, 
      HERE THE CODE TO SORT: I tried "count1" count1 or even the calculation, 
      nil, 
      nil, 
      nil
    ]
    columns[params[:iSortCol_0].to_i]
  end

和我的js:

aoColumns: [    
                false,
                { "asSorting": [ "asc","desc" ] },
                null,
                { "asSorting": [ "asc","desc" ] },
                null,
                null,
                null
            ]

有什么想法吗? 谢谢!

0 个答案:

没有答案