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
461-480 / 500 Alle rijen tonen
461dolor voluptasItaque quibusdam repellat in.No 6 JunEdit
462provident doloremque laudantiumVoluptas nihil enim placeat.No22 JanEdit
463excepturiNobis doloribus eos aut voluptatem eaque.No22 AugEdit
464culpaError deleniti qui quaerat sint.No17 AprEdit
465totamQui adipisci aspernatur qui non.No14 MarEdit
466autIllum corporis occaecati quia quo aut ratione voluptatem.No21 MarEdit
467in error praesentiumEarum temporibus quae laudantium.No 4 FebEdit
468officiisUt a qui quod saepe unde excepturi.No28 FebEdit
469natus autemSed deleniti iste et eos magnam delectus in sequi.Yes 8 OctEdit
470et nonQuia eaque consequatur minima ut pariatur.No25 JulEdit
471illo ut evenietSed esse et sit qui iste odit sint ex.No 9 MayEdit
472perspiciatisNihil qui dolore dignissimos dicta.No13 MarEdit
473voluptatum quiBlanditiis quisquam ut eos eum.No22 MarEdit
474possimusAut quia quia a et assumenda voluptas.No30 JunEdit
475rerum perspiciatis eumSoluta non et temporibus.No25 JunEdit
476facere voluptasOccaecati consectetur neque ullam dolores qui.Yes14 MarEdit
477et corruptiLabore non ab accusamus culpa aliquam dicta eaque.No10 JunEdit
478necessitatibusQui omnis tempora velit.No17 MarEdit
479provident exMolestias animi adipisci sed qui sit ducimus ut et.No25 OctEdit
480quas sapiente rerumQuos aut dolor error nihil at placeat quia id.No10 JulEdit

Fork me on GitHub