Search and Filters
Closed this issue · 2 comments
Hi Juan,
Great Job, thank you for that, I was able to implement jqgrid using rails 3.2 following your sample, however I'm still trying to get the search and filters working on that, I was looking in the code and documentation and I couldn't find it. Do you have any sample or piece of code doing the search with weill_paginate? and maybe the filters
Hi,
In order to use filters and search options you will have to create an ActiveRecord condition based on the params received from the grid. For example, if you receive these params:
'searchField' => 'invid', 'searchString' => '100', 'searchOper' => 'eq'
You should create a condition something like:
['invid = ?', '100']
And then use it when retrieving the records:
@invoices = Invoice.paginate(
:page => params[:page],
:per_page => params[:rows],
:conditions => ['invid = ?', '100'],
:order => order_by_from_params(params))
Would be better to create a new method called for example conditions_from_params
, similar to the order_by_from_params
that we already have, or, even better, move these helpers to the models.
Unfortunately, I'm not currently working with JqGrid, so I will not be able to make the changes, but I'll be happy
accepting pull requests.
Hope this helps!
Thank you I will try that out and let you know