leikind / wice_grid

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

wanted: change generated html id for table filter column #345

Closed webrups closed 7 years ago

webrups commented 7 years ago

situation: On my table I want to show all animals. I have 1 database table with all sort of selection names en they all belong to a selection_kinds via join table. Now I want to filter via dropdown on the different selections but for each selection_kind i want a separate dropdown to use for the filters.

so now I have 4 dropdowns in wicegrid, they all have the same attribute_id and assoc. but a different custom filter.

problem: only the first dropdown filter works. because the id is generated based in the attribute id and assoc.

questions:

  1. Can i override the genrated id? so that it is unique for all those 4 dropdowns?

other nasty own solution: I can change the database structure so I create a separate table for the separate selections I want to filter on. But that sounds like an ugly solution.

Steffen

leikind commented 7 years ago

I don't understand why you have 4 dropdown, and what your selection_kinds are. If you could explain your data model that would help.

webrups commented 7 years ago

a selection belongs to a selection_kind. in the selection table: I have the name for the selection, the id and the selection_kind_id so I can group the selections by selection_kind_id

so I want 4 dropdowns. each dropdown displays the selection names for his own selection_kind.

and I want to filter on those combined.

but currently only the first dropdown works. the other 3 has no effect. I think because the id fo those for dowpdown filters is exactly the same (browser inspect html)

and that is caused by the attribute_id and the assoc. they are all 4 the same. but the custom filters make it uniq. with works for showing the correct items in the dropdown.


so in my opinion the solution is simple: If I can make the generated id for the html unique the problem is solved. But there is no option in wicegrid to change that.

webrups commented 7 years ago

so I get the correct values into the 4 dropdowns because the custom filters is doing his job. but because the id is the same for all the 4 dropdowns in the html. only the first 1 works.

leikind commented 7 years ago

You should be using 1 dropdown with multiple election: https://github.com/leikind/wice_grid#multiple-selection

Otherwise how do you imagine 4 filters using the same field and the plugin magically figuring out that these 4 options should be unified with OR in the final SQL statement?