-
Notifications
You must be signed in to change notification settings - Fork 214
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
Add a last row to grid #41
Comments
There is no API specially for the last row, but you can try to do this via the custom row feature: http://grid.leikind.org/adding_rows , http://leikind.org/apis/wice_grid/files/README_rdoc.html#addingrowstothegrid . The trick will be to know when the rendered row is the last one. You can use @your_grid_object.resultset.count to get the number of records page. Is it Rails3? |
Yes, Rails 3. I tryed to develop the feature fallowing after_row and before_row examples: #lib/grid_renderer.rb #lib/wice_grid_view_helpers.rb
This works to handle current page resultset but i want to handle all pages resultset, can i to do this? I will pull request to you when all works. Thank you very much. |
In my first reply to your problem I meant that you can implement your solution without changing the source code of the plugin. For accessing all records you can try this http://grid.leikind.org/integration_with_application , or, from inside the plugin you can try to use grid.resultset_without_paging_with_user_filters |
Thanks leikind, worked now! But i think also what the last_row method is more semantic and easier than to use conditional in all after_row. What do you think, do you want my patch? Thank you one more time. |
Actually this seems like a possible feature. Let's just think what object will be injected into this block. In your code above I see that you are submitting the resultset. Do you think this is enough? I thought you want to perform calculations with all the records, and the resultset in the paginates mode represents only the current page (it's a will_paginate's paginate result object) |
No, removed this parameter, i am passing nil instead. call_block_as_erb_or_ruby(rendering, rendering.last_row_handler, nil) |
and what calculation do you do there in the last row? Do you access the grid object from there? |
Yes, i used the :with_resultset callback to get all registers and show one line with page calcs and other with general calcs, in respective columns. @grid_object.resultset.map(&:value).inject(:+) @controller.all.map(&:value).inject(:+) and others. |
Please submit the code if you like |
How does your grid declaration code with #last_column looks like by the way? |
i made now the pull request with the code and usage example. |
Merged. See 3.0.0pre3 |
Hi!
How can i to add a last row to grid?
I need to show cumulative values to specifc columns, id this possible with wice grid?
Thanks.
The text was updated successfully, but these errors were encountered: