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
21-40 / 500 Voir tous
et rerum laborumNoCancelled2016-04-29Edit
etNoCancelled2016-08-28Edit
exercitationem autNoClosed2016-05-21Edit
voluptate culpaNoResolved2016-06-24Edit
ab quiNoVerified2016-05-03Edit
quia mollitia delenitiNoAssigned2016-06-09Edit
eum velNoResolved2016-05-29Edit
laborum enim voluptasNoClosed2016-05-23Edit
etNoResolved2016-07-03Edit
corrupti molestiae abNoDuplicate2016-03-02Edit
debitis pariatur illoYesCancelled2016-08-29Edit
voluptatem ipsam liberoNoClosed2016-09-19Edit
voluptatemNoResolved2016-06-11Edit
illo voluptasNoClosed2016-07-02Edit
modiYesResolved2016-05-08Edit
placeatNoNew2016-05-29Edit
etNoStarted2016-06-06Edit
minima doloribus sedNoPostponed2016-10-16Edit
praesentium et idNoVerified2016-03-27Edit
dolorNoClosed2016-05-14Edit
TitleArchivedStatusDue Date
1-20 / 500 Voir tous
impedit aperiam liberoNoCancelled2016-07-27Edit
ut sintNoAssigned2016-10-21Edit
aliquam repudiandaeNoAssigned2016-04-20Edit
nisi quiNoVerified2016-05-16Edit
dicta pariaturNoPostponed2016-03-04Edit
molestiae autemYesResolved2016-10-26Edit
ut veniamNoPostponed2016-08-04Edit
nullaNoResolved2016-05-22Edit
quisquam in isteNoDuplicate2016-03-07Edit
rerum occaecatiNoCancelled2016-08-14Edit
aspernatur estYesStarted2016-06-21Edit
explicabo hicNoPostponed2016-04-15Edit
utNoClosed2016-07-18Edit
repellat consequatur velitNoNew2016-01-10Edit
est ut autNoNew2016-10-30Edit
omnisNoAssigned2016-02-05Edit
itaque suscipit commodiNoStarted2016-08-23Edit
necessitatibus commodiNoStarted2016-03-28Edit
id rem eaYesVerified2016-04-14Edit
aspernatur eligendi adipisciNoAssigned2016-06-08Edit

Fork me on GitHub