WiceGrid 3.6.0.pre4 examples

Auto reloading filters (external filters)

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:
Due date:

Added:

ID TitleArchivedStatusProject NameDue DateAdded
481-500 / 500 show all
481etNoClosedUltimate Website2016-10-232015-06-05 12:37:26Edit
482consequuntur eumNoDuplicateSuper Game2016-06-052015-05-01 12:37:26Edit
483laborum dictaNoVerifiedSuper Game2016-02-282015-05-09 12:37:26Edit
484quiaNoResolvedDivine Firmware2016-05-312015-05-06 12:37:26Edit
485ut teneturNoDuplicateSuper Game2016-10-132015-06-10 12:37:26Edit
486enim harum minimaNoResolvedSuper Game2016-09-252015-04-18 12:37:26Edit
487natus etNoNewUltimate Website2016-01-312015-05-14 12:37:26Edit
488doloribus veritatisNoClosedUltimate Website2016-04-062015-06-17 12:37:26Edit
489voluptatemNoDuplicateSuper Game2016-01-312015-06-02 12:37:27Edit
490maximeNoClosedUltimate Website2016-04-102015-05-21 12:37:27Edit
491modi nesciuntNoStartedSuper Game2016-05-102015-05-04 12:37:27Edit
492sed atNoStartedSuper Game2016-06-142015-05-13 12:37:27Edit
493estNoVerifiedDivine Firmware2016-02-062015-05-28 12:37:27Edit
494fugiat quaeratNoDuplicateUltimate Website2016-06-102015-05-30 12:37:27Edit
495qui ut inNoVerifiedUltimate Website2016-10-082015-04-21 12:37:27Edit
496velit non pariaturYesPostponedDivine Firmware2016-09-062015-04-07 12:37:27Edit
497impedit quoNoNewSuper Game2016-07-092015-04-11 12:37:27Edit
498sedYesResolvedDivine Firmware2016-07-072015-04-05 12:37:27Edit
499voluptatemNoResolvedDivine Firmware2016-06-192015-05-09 12:37:27Edit
500vel eaYesStartedUltimate Website2016-03-302015-04-16 12:37:27Edit

Fork me on GitHub