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

Problem with sorting/filtering when using associated tables #246

Closed Nickk4 closed 9 years ago

Nickk4 commented 9 years ago

Sorting and filtering for associated tables does not seem to work. I use wice_grid 3.5.0, Firefox 39, Rails 4.2.3, PostgresQL, and the console shows no javascript errors. The error message upon sorting or filtering reads missing FROM-clause entry for table "users" where User is the associated table. I've posted the details to http://stackoverflow.com/q/31638085/4499505.

leikind commented 9 years ago

Use :include in :initialize_grid to include associated tables. http://wicegrid.herokuapp.com/joining_tables. It's in the documentation.

Nickk4 commented 9 years ago

Thanks, that indeed takes care of the error but another related issue popped up: For two of the columns it always sorts on basis of the first of these two columns, even if I click on the second column. Added the details to http://stackoverflow.com/q/31638085/4499505.

leikind commented 9 years ago

Here is the answer to your problem https://github.com/leikind/wice_grid#joined-associations-referring-to-the-same-table

Can you please stop posting questions which are explained in the documentation, and read the docs attentively?