WiceGrid 3.6.0.pre4 examples

Auto reloading filters (two grids on page)

An example with 2 independant autoreloading grids on one page.

  • # encoding: utf-8
    class AutoReloads3Controller < 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'
          }
        )
        @tasks_grid2 = initialize_grid(Task,
         name: 'grid2',
         custom_order: {
           'tasks.priority_id' => 'priorities.name',
           'tasks.status_id' => 'statuses.position',
           'tasks.project_id' => 'projects.name'
         }
        )
      end
    end
    
  • <%= define_grid(grid,  hide_submit_button: true) do |g|
    
    
      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:  '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   do |task|
        link_to('Edit', edit_task_path(task))
      end
    end -%>
  • .well
      %h2= current_page_title
      %p
        An example with 2 independant autoreloading grids on one page.
    
    = show_code
    
    = render   'grid', grid: @tasks_grid
    = render   'grid', grid: @tasks_grid2
    
    
    .row-fluid
      .col-md-2
        Title:
      .col-md-4
        = grid_filter @tasks_grid, :title
    
      .col-md-2
        Title:
      .col-md-4
        = grid_filter @tasks_grid2, :title
    
    
    
    .row-fluid
      .col-md-2
        Archived:
      .col-md-4
        = grid_filter @tasks_grid, :archived
    
    
      .col-md-2
        Archived:
      .col-md-4
        = grid_filter @tasks_grid2, :archived
    
    
    
    .row-fluid
      .col-md-2
        Status:
      .col-md-4
        = grid_filter @tasks_grid, :status_id
    
      .col-md-2
        Status:
      .col-md-4
        = grid_filter @tasks_grid2, :status_id
    
    
    
    .row-fluid
      .col-md-2
        Due date:
      .col-md-4
        = grid_filter @tasks_grid, :due_date
    
      .col-md-2
        Due date:
      .col-md-4
        = grid_filter @tasks_grid2, :due_date
    
    
    .row-fluid
      .col-md-6
        .external-buttons.grid1
          %button.btn.btn-default.wg-external-reset-button{'data-grid-name' => 'grid'} Reset
    
      .col-md-6
        .external-buttons.grid2
          %button.btn.btn-default.wg-external-reset-button{'data-grid-name' => 'grid2'} Reset
    
    
    .row-fluid
      .col-md-6
        = render_grid(@tasks_grid)
      .col-md-6
        = render_grid(@tasks_grid2)
    
Title:
Title:
Archived:
Archived:
Status:
Status:
Due date:

Due date:

TitleArchivedStatusDue Date
81-100 / 500 show all
ad quo dolorNoStarted2016-05-18Edit
utNoCancelled2016-01-12Edit
enimNoDuplicate2016-10-14Edit
doloreNoResolved2016-05-28Edit
voluptatibus inventoreYesClosed2016-06-03Edit
adipisciNoStarted2016-02-07Edit
nostrumNoClosed2016-03-31Edit
culpaNoPostponed2016-10-19Edit
provident consequatur remNoResolved2016-08-20Edit
commodi et quisNoCancelled2016-05-30Edit
quaeratNoAssigned2016-06-17Edit
est praesentiumNoClosed2016-01-19Edit
autNoCancelled2016-09-20Edit
officiisNoNew2016-02-01Edit
quibusdam beatae adYesVerified2016-03-06Edit
impedit explicabo voluptatemNoVerified2016-10-25Edit
voluptatem facilis etNoStarted2016-05-26Edit
aperiam rerumYesClosed2016-07-19Edit
solutaNoAssigned2016-10-12Edit
autem nonNoResolved2016-08-04Edit
TitleArchivedStatusDue Date
441-460 / 500 show all
in autNoStarted2016-08-25Edit
ut voluptatemNoNew2016-07-26Edit
ullam laudantium commodiNoNew2016-10-25Edit
asperiores quisYesVerified2016-02-29Edit
delectusNoNew2016-08-29Edit
ut et sitNoClosed2016-07-06Edit
animi accusantium utNoClosed2016-10-15Edit
tempore aliquam rationeNoNew2016-01-21Edit
dolores sedNoClosed2016-01-31Edit
distinctio aspernaturNoClosed2016-05-16Edit
expedita nihilNoDuplicate2016-08-01Edit
illum et voluptatemYesCancelled2016-02-03Edit
omnisNoPostponed2016-05-19Edit
similique enim odioNoDuplicate2016-01-11Edit
etNoNew2016-06-10Edit
inventore voluptasNoNew2016-04-01Edit
asperiores qui nonNoNew2016-05-16Edit
quisNoAssigned2016-08-18Edit
et rerumNoDuplicate2016-09-15Edit
consequatur nemoNoVerified2016-08-03Edit

Fork me on GitHub