An example with an autoreloading grid with detached filters.
# encoding: utf-8 class AutoReloads2Controller < ApplicationController def index @tasks_grid = initialize_grid(Task, custom_order: { 'tasks.priority_id' => 'priorities.name', 'tasks.status_id' => 'statuses.position', 'tasks.project_id' => 'projects.name' }, order: 'id', order_direction: 'asc' ) end end
<%= define_grid(@tasks_grid, hide_submit_button: true) do |g|
g.column name: 'ID', attribute: 'id', auto_reload: true, detach_with_id: :id, filter_type: :range
g.column name: 'Title', attribute: 'title', auto_reload: true, negation: true, detach_with_id: :title
g.column name: 'Archived', attribute: 'archived', auto_reload: true, detach_with_id: :archived do |rec|
rec.archived? ? 'Yes' : 'No'
end
g.column name: 'Status', attribute: 'status_id', custom_filter: Status.to_dropdown, auto_reload: true, detach_with_id: :status_id 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, detach_with_id: :project_id do |task|
task.project.name if task.project
end
g.column name: 'Due Date', attribute: 'due_date', auto_reload: true, detach_with_id: :due_date do |task|
task.due_date if task.due_date
end
g.column name: 'Added', attribute: 'created_at', auto_reload: true, detach_with_id: :created_at do |task|
task.created_at.to_s(:db)
end
g.column do |task|
link_to('Edit', edit_task_path(task))
end
end -%>
.well %h2= current_page_title %p An example with an autoreloading grid with detached filters. = show_code = render 'grid' .row .col-md-2 ID: .col-md-10 = grid_filter @tasks_grid, :id .row .col-md-2 Title: .col-md-10 = grid_filter @tasks_grid, :title .row .col-md-2 Archived: .col-md-10 = grid_filter @tasks_grid, :archived .row .col-md-2 Status: .col-md-10 = grid_filter @tasks_grid, :status_id .row .col-md-2 Project: .col-md-10 = grid_filter @tasks_grid, :project_id .row .col-md-2 Due date: .col-md-10 = grid_filter @tasks_grid, :due_date .row .col-md-2 Added: .col-md-10 = grid_filter @tasks_grid, :created_at .row .col-md-12 .external-buttons %button.btn.btn-default.wg-external-reset-button{'data-grid-name' => 'grid'} Reset .row .col-md-12 = render_grid(@tasks_grid)
ID | Title | Archived | Status | Project Name | Due Date | Added | |
---|---|---|---|---|---|---|---|
1-20 / 500 Voir tous | |||||||
1 | impedit aperiam libero | No | Cancelled | Divine Firmware | 2016-07-27 | 2015-05-22 12:37:18 | Edit |
2 | ut sint | No | Assigned | Divine Firmware | 2016-10-21 | 2015-04-09 12:37:18 | Edit |
3 | aliquam repudiandae | No | Assigned | Divine Firmware | 2016-04-20 | 2015-03-21 12:37:18 | Edit |
4 | nisi qui | No | Verified | Divine Firmware | 2016-05-16 | 2015-03-18 12:37:18 | Edit |
5 | dicta pariatur | No | Postponed | Divine Firmware | 2016-03-04 | 2015-04-19 12:37:18 | Edit |
6 | molestiae autem | Yes | Resolved | Ultimate Website | 2016-10-26 | 2015-05-16 12:37:18 | Edit |
7 | ut veniam | No | Postponed | Ultimate Website | 2016-08-04 | 2015-05-10 12:37:18 | Edit |
8 | nulla | No | Resolved | Divine Firmware | 2016-05-22 | 2015-04-25 12:37:18 | Edit |
9 | quisquam in iste | No | Duplicate | Ultimate Website | 2016-03-07 | 2015-06-07 12:37:18 | Edit |
10 | rerum occaecati | No | Cancelled | Super Game | 2016-08-14 | 2015-05-22 12:37:18 | Edit |
11 | aspernatur est | Yes | Started | Super Game | 2016-06-21 | 2015-03-24 12:37:18 | Edit |
12 | explicabo hic | No | Postponed | Divine Firmware | 2016-04-15 | 2015-05-26 12:37:18 | Edit |
13 | ut | No | Closed | Ultimate Website | 2016-07-18 | 2015-03-22 12:37:18 | Edit |
14 | repellat consequatur velit | No | New | Ultimate Website | 2016-01-10 | 2015-05-06 12:37:18 | Edit |
15 | est ut aut | No | New | Divine Firmware | 2016-10-30 | 2015-04-17 12:37:18 | Edit |
16 | omnis | No | Assigned | Super Game | 2016-02-05 | 2015-03-21 12:37:18 | Edit |
17 | itaque suscipit commodi | No | Started | Super Game | 2016-08-23 | 2015-03-30 12:37:18 | Edit |
18 | necessitatibus commodi | No | Started | Super Game | 2016-03-28 | 2015-03-27 12:37:18 | Edit |
19 | id rem ea | Yes | Verified | Super Game | 2016-04-14 | 2015-03-29 12:37:18 | Edit |
20 | aspernatur eligendi adipisci | No | Assigned | Ultimate Website | 2016-06-08 | 2015-05-30 12:37:18 | Edit |