Skip to content

Instantly share code, notes, and snippets.

@bronson
Created February 16, 2010 00:55
Show Gist options
  • Save bronson/305165 to your computer and use it in GitHub Desktop.
Save bronson/305165 to your computer and use it in GitHub Desktop.
# minor improvement to http://blog.js.hu/2010/01/07/unobtrusive-jqgrid-on-rails-a-la-2dconcept-but-with-searchlogic/
# (would have commented but blog.js.hu isn't sending me a registration email)
if params[:_search].present?
filters = {}
if params[:_search] == "true"
searchable_columns.each do |param|
filters["#{param}_like"] = params[param] if params[param].present?
end
end
if params[:sidx].present?
order = params[:sord] == "desc" ? "descend" : "ascend"
filters[:order] = "#{order}_by_#{params[:sidx]}"
end
finder = finder.search(filters)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment