WiceGrid 3.6.0.pre4 examples

External filters

Filters can also be detached from the grid table. This is a 3-step process.

  1. First, define the grid with helper define_grid instead of grid . Everything should be done the same way as with grid, but every column which will have an external filter, add detach_with_id: :some_filter_name in the column definition.
  2. Then use grid_filter(grid, :some_filter_name) to render filters.
  3. Finally, use render_grid(@grid) to actually output the grid table .
  • # encoding: utf-8
    class DetachedFiltersController < ApplicationController
      def index
        @tasks_grid = initialize_grid(Task)
      end
    end
    
  • .well
      %h2= current_page_title
      %p
        Filters can also be detached from the grid table. This is a 3-step process.
    
      %ol
        %li
          First, define the grid with helper
          %code define_grid
          instead of
          %code grid
          \. Everything should be done the same way as with
          %code grid, but every column which will have an external filter, add
          %code detach_with_id: :some_filter_name
          in the
          %code column
          definition.
    
        %li
          Then use
          %code grid_filter(grid, :some_filter_name)
          to render filters.
    
        %li
          Finally, use
          %code render_grid(@grid)
          to actually output the grid table
          \.
    
    = show_code
    
    = render   'grid'
    
    
    .row
      .col-md-2
        ID:
      .col-md-10
        = grid_filter @tasks_grid, :id_filter
    
    .row
      .col-md-2
        Title:
      .col-md-3
        = grid_filter @tasks_grid, :title_filter
      .col-md-7
    
    
    .row
      .col-md-2
        Description:
      .col-md-3
        = grid_filter @tasks_grid, :description_filter
      .col-md-7
    
    .row
      .col-md-2
        Archived:
      .col-md-10
        = grid_filter @tasks_grid, :archived_filter
    
    
    .row
      .col-md-2
        Due date:
      .col-md-10
        = grid_filter @tasks_grid, :due_date
    
    
    .row-fluid
      .col-md-12
        .external-buttons
          %button.btn.btn-primary.wg-external-submit-button{'data-grid-name' => 'grid'} Submit
          %button.btn.btn-default.wg-external-reset-button{'data-grid-name' => 'grid'} Reset
    
    .row-fluid
      .col-md-12
    
        = render_grid(@tasks_grid)
    
  • <%= define_grid(@tasks_grid, hide_submit_button: true, hide_reset_button: true) do |g|
    
      g.column name:  'ID', attribute: 'id', detach_with_id: :id_filter
    
      g.column name:  'Title', attribute: 'title', detach_with_id: :title_filter
    
      g.column  name:  'Description', attribute: 'description', detach_with_id: :description_filter
    
      g.column  name:  'Archived', attribute: 'archived', detach_with_id: :archived_filter do |task|
        task.archived? ? 'Yes' : 'No'
      end
    
    
      g.column name:  'Due Date', attribute: 'due_date', detach_with_id: :due_date do |task|
        task.due_date.to_s(:short)
      end
    
    
      g.column   do |task|
        link_to('Edit', edit_task_path(task))
      end
    
    end -%>
    
ID:
Title:
Description:
Archived:
Due date:

IDTitleDescriptionArchivedDue Date
21-40 / 500 Alle rijen tonen
21et rerum laborumVelit consequatur quas sunt perspiciatis quae nihil.No29 AprEdit
22etReiciendis non officia aut omnis quia minima.No28 AugEdit
23exercitationem autVoluptatum aut earum at est deserunt.No21 MayEdit
24voluptate culpaEt velit ut libero dolores.No24 JunEdit
25ab quiFugit id error esse.No 3 MayEdit
26quia mollitia delenitiFugit voluptatem recusandae soluta voluptatum consequuntur est voluptatem quas.No 9 JunEdit
27eum velUllam tenetur culpa error fugit sunt.No29 MayEdit
28laborum enim voluptasDignissimos sed laudantium in consequatur quaerat molestias optio maxime.No23 MayEdit
29etEst nesciunt accusantium repudiandae est officia ipsa.No 3 JulEdit
30corrupti molestiae abRepellat ipsa quis quam alias dolores itaque.No 2 MarEdit
31debitis pariatur illoTemporibus velit id et porro dolor.Yes29 AugEdit
32voluptatem ipsam liberoBlanditiis omnis enim voluptas fugit molestiae.No19 SepEdit
33voluptatemDolorem saepe et aspernatur.No11 JunEdit
34illo voluptasEsse et fuga voluptate eveniet qui.No 2 JulEdit
35modiAnimi quod iste sunt.Yes 8 MayEdit
36placeatQuia aut eligendi aliquid.No29 MayEdit
37etIncidunt eum consequatur qui et quis.No 6 JunEdit
38minima doloribus sedEst ipsum aut quam libero dolorem praesentium ut repellendus.No16 OctEdit
39praesentium et idExpedita laborum incidunt natus.No27 MarEdit
40dolorSapiente voluptas aspernatur non nulla illo aperiam et.No14 MayEdit

Fork me on GitHub