leikind / wice_grid

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

Nested model #220

Closed clubbavi closed 9 years ago

clubbavi commented 9 years ago

Hello,

How can I use wice grid if I have multiple nested models? Ex: A has_many :B, B has_many :C. How can we access C in this case? initialize_grid(A, :include => [:B] and then?

Can anyone help?

Thanks

leikind commented 9 years ago
:include =>  [:assoc1, {:assoc2: => {:assoc3 => [:assoc4, :assoc5] }} ]  
clubbavi commented 9 years ago

Just one question on this: If I want to show the has_may relations in multiple lines, then what is the correct syntax for that?

As : g.column :column_name => 'Category',:attribute_name => 'name', :model_class=> 'ArticleCategory' do |administrator_article| administrator_article.article_categories.collect{|ac| ac.name}.join(',') end

this will bring the data in one line. If I want to show these in multiple lines?

leikind commented 9 years ago

I assume this is a many-to-many association. And you want to have a line per each combination of article/category, right? Then you should create an AR model for your many-to-many join table, and have a grid for this model instead of a grid for articles.

Does it make sense?

Please use github markdown!

clubbavi commented 9 years ago

The other way around. Yes, I got that. It is now working as expected. Thanks a lot.