WiceGrid 3.6.0.pre4 examples

Custom filters (one table)

Just like options_for_select , :custom_filter can take arguments in the form of a hash, an array of two element arrays, or just an array.

custom_filter: :auto will instruct WiceGrid to figure out the list of possible values by running a SELECT DISTINCT `column` FROM `table` query on the table.

  • # encoding: utf-8
    class CustomFilters1Controller < ApplicationController
      def index
        @versions_grid1 = initialize_grid(Version, name: 'g1', per_page: 5)
        @versions_grid2 = initialize_grid(Version, name: 'g2', per_page: 5)
        @versions_grid3 = initialize_grid(Version, name: 'g3', per_page: 5)
        @versions_grid4 = initialize_grid(Version, name: 'g4', per_page: 5)
      end
    end
    
  • <%= grid(@versions_grid2) do |g|
    
      g.column name:  'Project', attribute: 'name', assoc: :project, filter: false
    
      g.column name:  'Version name', attribute: 'name', filter: false
    
      g.column name:  'Status', attribute: 'status',
               custom_filter: [['Development', 'development'], ['Testing', 'testing'], ['Production', 'production']]
    end -%>
    
  • <%= grid(@versions_grid3) do |g|
    
      g.column name:  'Project', attribute: 'name', assoc: :project, filter: false
    
      g.column name:  'Version name', attribute: 'name', filter: false
    
      g.column name:  'Status', attribute: 'status',
               custom_filter: ['development', 'testing', 'production']
    end -%>
    
  • <%= grid(@versions_grid1) do |g|
    
      g.column name:  'Project', attribute: 'name', assoc: :project, filter: false
    
      g.column name:  'Version name', attribute: 'name', filter: false
    
      g.column name:  'Status', attribute: 'status', custom_filter: {'Development' => 'development', 'Testing' => 'testing', 'Production' => 'production'}
    end -%>
    
  • <%= grid(@versions_grid4) do |g|
    
      g.column name:  'Project', attribute: 'name', assoc: :project, filter: false
    
      g.column name:  'Version name', attribute: 'name', filter: false
    
      g.column name:  'Status', attribute: 'status', custom_filter: :auto
    end -%>
    
  • .well
      %h2= current_page_title
      %p
        Just like
        %code options_for_select
        ,
        %code :custom_filter
        can take arguments in the form of a hash, an array of two element arrays, or just an array.
      %p
        %code custom_filter: :auto
        will instruct WiceGrid to figure out the list of possible values by running a
        %code SELECT DISTINCT `column` FROM `table`
        query on the table.
    
    = show_code
    
    .row-fluid
      .col-md-6
        = render   'g1'
    
      .col-md-6
        = render   'g2'
    
    
    .row-fluid
      .col-md-6
        = render   'g3'
    
      .col-md-6
        = render   'g4'
    
Project Version nameStatus
Divine Firmware8.0production
Divine Firmware6.0production
Divine Firmware7.1development
Super Game88.1development
Super Game1.0development
ProjectVersion nameStatus
Ultimate Website3.0testing
Ultimate Website2.0development
Ultimate Website1.2development
Ultimate Website1.1testing
Ultimate Website1.0testing
ProjectVersion nameStatus
Ultimate Website3.0testing
Ultimate Website2.0development
Ultimate Website1.2development
Ultimate Website1.1testing
Ultimate Website1.0testing
ProjectVersion nameStatus
Ultimate Website3.0testing
Ultimate Website2.0development
Ultimate Website1.2development
Ultimate Website1.1testing
Ultimate Website1.0testing

Fork me on GitHub