Method
current_page_records
sent to the grid object returns a list of all ActiveRecord objects currently displayed on the page.
Method
all_pages_records
returns a list of all ActiveRecord objects throughout all pages of the current selection.
all_pages_records
causes an additional SQL query to be executed and has to be used with care.
Both methods can be used after the grid definition only.
# encoding: utf-8 class IntegrationWithApplicationViewController < ApplicationController def index @tasks_grid = initialize_grid(Task, include: [:priority, :status, :project, :assigned_users], order: 'statuses.name', name: 'g', per_page: 10, custom_order: { 'tasks.priority_id' => 'priorities.name', 'tasks.status_id' => 'statuses.position', 'tasks.project_id' => 'projects.name' } ) end end
<%= grid(@tasks_grid, hide_submit_button: true) do |g|
g.column name: 'ID', attribute: 'id', filter: false
g.column name: 'Title', attribute: 'title', auto_reload: true
g.column name: 'Priority', attribute: 'priority_id', custom_filter: Priority.to_dropdown, auto_reload: true do |task|
task.priority.name if task.priority
end
g.column name: 'Status', attribute: 'status_id', custom_filter: Status.to_dropdown, auto_reload: true do |task|
task.status.name if task.status
end
g.column name: 'Project Name', attribute: 'project_id', custom_filter: Project.to_dropdown, auto_reload: true do |task|
task.project.name if task.project
end
g.column name: 'Archived', attribute: 'archived', auto_reload: true do |task|
task.archived? ? 'Yes' : 'No'
end
g.column name: 'Added', attribute: 'created_at', auto_reload: true do |task|
task.created_at.to_s(:short)
end
end -%>
.well %h2= current_page_title %p Method %code current_page_records sent to the grid object returns a list of all ActiveRecord objects currently displayed on the page. %p Method %code all_pages_records returns a list of all ActiveRecord objects throughout all pages of the current selection. %code all_pages_records causes an additional SQL query to be executed and has to be used with care. %p Both methods can be used after the grid definition only. = show_code = render 'grid' .row-fluid .col-md-6 .well - current_page_records = @tasks_grid.current_page_records = current_page_records.size records on the current page: = current_page_records.map(&:id).to_sentence .col-md-6 .well - all_pages_records = @tasks_grid.all_pages_records = all_pages_records.size records throughout all pages: = all_pages_records.map(&:id).to_sentence
ID | Title | Priority | Status | Project Name | Archived | Added | |
---|---|---|---|---|---|---|---|
| |||||||
1-10 / 500 Sýna allt | |||||||
2 | ut sint | Anecdotic | Assigned | Divine Firmware | No | 09 Apr 12:37 | |
61 | quia architecto | Normal | Assigned | Divine Firmware | No | 15 May 12:37 | |
91 | quaerat | High | Assigned | Divine Firmware | No | 08 Jun 12:37 | |
279 | et sit | Low | Assigned | Super Game | No | 01 Jun 12:37 | |
302 | eligendi vel | Normal | Assigned | Super Game | No | 24 Mar 12:37 | |
334 | sit | Assigned | Divine Firmware | No | 03 Apr 12:37 | ||
377 | quam qui quibusdam | Assigned | Divine Firmware | No | 24 Mar 12:37 | ||
404 | at aliquam corrupti | Anecdotic | Assigned | Super Game | No | 23 May 12:37 | |
436 | accusantium | High | Assigned | Super Game | No | 05 Apr 12:37 | |
179 | omnis et facilis | Low | Assigned | Divine Firmware | No | 29 Mar 12:37 |