Hello
I am using Ruby on rails and JQgrid. Everything works fine but when the grid load the data it is sorted in a way I don't want. I need to be sorted descendent in the ID column. I was not the one who developed this software so I don't know exactly what to change. This code is in the helper of the quote controller and I think here is where I have to change it. Someone told me to use Quote.order('id DESC') which is in the last line. I put it in the second line but nor of them is working properly. Could someone please tell me what needs to be added in order to accomplish it? There is also code in javascript. But that is very complex. I think I don't need to change that.
I really appreciate. I have more than 2 moths trying to solve it. Thanks.
def format_quote_grid!
Quote.grid.update({
:title => "Quotes",
:pager => true,
:search_toolbar => :hidden,
:resizable => false,
:height => :auto,
:except => [:contacts],
:rows_per_page => 10}) { |grid|
grid.column :id, :label => "Number", :width => 50#, :proc => lambda {|record| link_to record.number, quote_path(record) }
grid.column :job_name, :width => 140, :proc => lambda {|record| link_to record.job_name, quote_path(record) }
grid.column :category, :width => 60
grid.column :needs_installation, :width => 60
grid.column :contact_id, :hidden => true
grid.column :business_id, :hidden => true
grid.column :contact_name, :label => "Contact", :width => 100, :sortable => false, :proc => lambda {|record| link_to(record.contact.name, record.contact) if record.contact.present? }
grid.column :business_name, :label => "Business", :width => 100, :sortable => false, :proc => lambda {|record| link_to(record.business.name, record.business) if record.business.present? }
grid.column :scope_of_work_id, :hidden => true
grid.column :markup, :hidden => true
grid.column :notes, :hidden => true
grid.column :shred, :hidden => true
grid.column :printed_at, :hidden => true
grid.column :created_at, :hidden => true
grid.column :updated_at, :hidden => true
grid.column :user_id, :hidden => true
grid.column :actions, :width => 200, :sortable => false, :searchable => false, :proc => lambda {|record|
permissioned_actions(record) do |p|
p.show_link
p.link('Printable', printable_quote_path(record), :show, record)
p.edit_link
p.destroy_link
p.link('RFQ', request_for_quote_path(record.scope_of_work.request_for_quote_id), :show, record.scope_of_work) if record.scope_of_work.present?
p.correspondence_link
p.resources_link
p.link(record.work_order.number, work_order_path(record)) if record.work_order
end
}
Quote.order('id DESC') #hecho por mi
}
end
Ok, from one of your earlier posts on this subject, it seems you are using Gridify.
Gridify seems to support the following options:
So, I would add the following just below
:except => [:contacts],
Hope this helps.