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
    
  • .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)
    
  • <%= 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 -%>
ID:
Title:
Archived:
Status:
Project:
Due date:

Added:

ID TitleArchivedStatusProject NameDue DateAdded
461-480 / 500 show all
461dolor voluptasNoCancelledUltimate Website2016-06-062015-06-05 12:37:26Edit
462provident doloremque laudantiumNoDuplicateUltimate Website2016-01-222015-03-14 12:37:26Edit
463excepturiNoNewSuper Game2016-08-222015-03-18 12:37:26Edit
464culpaNoCancelledUltimate Website2016-04-172015-05-23 12:37:26Edit
465totamNoResolvedSuper Game2016-03-142015-04-23 12:37:26Edit
466autNoVerifiedDivine Firmware2016-03-212015-03-19 12:37:26Edit
467in error praesentiumNoClosedDivine Firmware2016-02-042015-05-12 12:37:26Edit
468officiisNoClosedSuper Game2016-02-282015-06-07 12:37:26Edit
469natus autemYesResolvedDivine Firmware2016-10-082015-06-10 12:37:26Edit
470et nonNoCancelledSuper Game2016-07-252015-06-19 12:37:26Edit
471illo ut evenietNoDuplicateSuper Game2016-05-092015-04-01 12:37:26Edit
472perspiciatisNoCancelledUltimate Website2016-03-132015-03-26 12:37:26Edit
473voluptatum quiNoVerifiedUltimate Website2016-03-222015-06-11 12:37:26Edit
474possimusNoResolvedSuper Game2016-06-302015-03-23 12:37:26Edit
475rerum perspiciatis eumNoCancelledDivine Firmware2016-06-252015-04-20 12:37:26Edit
476facere voluptasYesClosedDivine Firmware2016-03-142015-05-21 12:37:26Edit
477et corruptiNoNewSuper Game2016-06-102015-05-03 12:37:26Edit
478necessitatibusNoCancelledDivine Firmware2016-03-172015-05-10 12:37:26Edit
479provident exNoVerifiedSuper Game2016-10-252015-05-02 12:37:26Edit
480quas sapiente rerumNoPostponedUltimate Website2016-07-102015-04-25 12:37:26Edit

Fork me on GitHub