leikind / wice_grid

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

Keep anchor paramater when applying filters #168

Closed mdebo closed 10 years ago

mdebo commented 10 years ago

Hi,

I have a web page with multiple tabs, working with the system of anchors. I use your grid on the third tabs. The problem is applying filters does not keep anchor params in url. The result is each time i apply filter, i'm redirected to the first tabs. Is there any option to keep anchor params(#....) in url when applying filters?

Thanks!

leikind commented 10 years ago

Is there just one grid?

mdebo commented 10 years ago

Yes

leikind commented 10 years ago

Tabs always have some kind of a JS API to change the active tab. Make sure that when a page is the result of a wice_grid reload a JS function is triggered which sets the active tab correctly. You can use :extra_request_parameters to add an HTTP parameter which would mean that the request originates from the grid https://github.com/leikind/wice_grid/blob/rails3/lib/wice/helpers/wice_grid_view_helpers.rb#L20

mdebo commented 10 years ago

I understand. When we apply filters, current url params are conserved. But hash isn't, and that is my problem. So actually the only way to do it is to use :extra_request_parameters to add an HTTP parameter, and then use this http parameter to set the hash to the url.. that's it?

leikind commented 10 years ago

Anchors are not sent by the client to the server, when requesting a resource. That's HTTP.

mdebo commented 10 years ago

Ok, i have used :extra_request_parameters to add an extra parameter with the desired tab, and write a JS function to manually add anchor by using it. It works fine

Thank you for your reactivity