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:

IDTitle DescriptionArchivedDue Date
41-60 / 500 Alle rijen tonen
42autEt eaque dignissimos magnam.No25 AugEdit
352autemUt provident voluptates dolor.No 8 JanEdit
315autemSapiente sit est laboriosam quo officiis ab.No 8 JulEdit
104autemMinima consequatur explicabo deleniti iusto officiis debitis doloremque rerum.No23 MayEdit
70autemSit ipsa aut qui quia voluptatem omnis.No 4 AugEdit
332autem etDolorem qui qui repudiandae eveniet mollitia est exercitationem rerum.No28 AugEdit
100autem nonMinus autem provident ex culpa sit.No 4 AugEdit
301autem perspiciatisSit enim itaque in earum cumque est et.No10 FebEdit
105autem quiaVelit voluptas impedit officia illo eveniet ullam.Yes25 JunEdit
244autem sintEarum quibusdam rerum amet quae laudantium.Yes30 JunEdit
391aut estVelit distinctio necessitatibus culpa debitis non eos molestiae rerum.No21 OctEdit
336aut quis aspernaturAliquam fuga similique facilis accusamus reprehenderit.No21 AprEdit
160aut voluptatesEarum odio voluptatem nulla.No14 AprEdit
158aut voluptatibus autLaudantium quae beatae et architecto voluptatem libero et.No19 AugEdit
318beataeQuaerat veniam architecto est.No19 MarEdit
202beataeVel cupiditate quis autem.No19 AugEdit
164beatae consecteturSimilique dolorem provident et accusantium aliquid inventore omnis.No29 FebEdit
225beatae porroAut mollitia et ut.No14 OctEdit
241blanditiis natusImpedit sit ea ut et.No 7 JunEdit
373commodiSit minima ab voluptas dolorem cumque.No 9 MarEdit

Fork me on GitHub