leikind / wice_grid

A Rails grid plugin to create grids with sorting, pagination, and (automatically generated) filters
MIT License
536 stars 215 forks source link

Use the custom filter on certain links #317

Open HansenAB opened 7 years ago

HansenAB commented 7 years ago

Hi, What I am trying to do is when a user click a specific link, it should redirect this user to the grid with the custom filter condition. For instance I have a custom filter "fee paid", it has two options "paid" and "not paid" g.column name: 'Payment', attribute: 'closed', assoc: [:order_item, :order], custom_filter: {'Paid' => 1, 'Unpaid' => 0} do |app|

I want that so when a user click a link on other page, it redirect to this page only showing the paid record. It is kind of like combine the two steps(load the page and use the filter) into one step. How should I do it?

leikind commented 7 years ago

look at the source of _grid.html.erb on this page http://wicegrid.herokuapp.com/custom_filter_params

HansenAB commented 7 years ago

Thank you, it helps, but still there is a problem. I think it is caused by ordering or association, I am not sure.

The link generated by clicking the filter is: applications?grid%5Bf%5D%5Borders.closed%5D%5B%5D=1 But the link generated by the helped is: applications?grid%5Bf%5D%5Bclosed%5D%5B%5D=1 The part orders is missing

Here is the controller: included=[:user, order_item: {order: :payments}}]

@applications_grid = initialize_grid(
    applications,
    include: included,
    order: 'applications.updated_at',
    order_direction: 'asc',
    per_page: 50
)`

I am not sure what is happening here

leikind commented 7 years ago

probably a bug.