-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
how to display in a html.erb template #12
Comments
Hi Ben, Using the example from the README, in your erb template you could do this:
For the row data, when you build the grid object it would depend on whether you specify a pivot field or not. This can make things a lot simpler, depending on your use-case. See this README section. One final note, just to be clear, I'm assuming you are using The usage section in the README should hopefully be clear enough in showing how to use this gem. Let mw know if you need any more help. Ed. |
Hi thx Ed Another question; This is given in the main page:
Now you will notice the quarter attribute. In my particular case, the quarter attribute is in fact a related child record. Let me perhaps explain by adapting the above example. Order
Quarter
A city has many quarters. And quarter belongs to a city. How would I display the name of the quarter in the above pivot table example.? in other words: g = PivotTable::Grid.new do |g| I hope im making sense? clarifications much appreciated. rgds Ben |
Hi Ben If I understand your example correctly I don't think this will work. I'm only handling a single level of object i.e. nested objects are not supported. However, I think you can work around this by changing the query you are using to generate your result set. So rather than having related objects, you could change the query to return a composite object i.e. include the joined tables in the query result, rather than using ActiveRecord to load associated objects. Additionally, it sounds like you have a one-to-many relationship between Ed. |
thank you for your response mr James, I will get back to on the specifics of this problem. I suspect it's a common one, hence my interest in it. rgds, Ben |
Stale issue, closing... |
Hi
thx for publishing your gem. how do I actually display the table in an html.erb? I can build it but displaying it? I noticed that the build command - this presumably goes into the controller. but what do I put in view template between these tags: <% %> to make the pivot table display?
rgds
Ben
The text was updated successfully, but these errors were encountered: