WiceGrid 3.6.0.pre4 examples

Custom filters (null values)

Strings null and not null in custom_filter values are treated speacially and result in IS NULL and IS NOT NULL WHERE-clauses.

  • # encoding: utf-8
    class NullValuesController < ApplicationController
      def index
        @tasks_grid = initialize_grid(Task,
          custom_order: {
            'tasks.priority_id' => 'priorities.name'
          }
        )
      end
    end
    
  • .well
      %h2= current_page_title
      %p
        Strings
        %code null
        and
        %code not null
        in
        %code custom_filter
        values
        are treated speacially and result in
        %code IS NULL
        and
        %code IS NOT NULL
        WHERE-clauses.
    
    = show_code
    
    .row-fluid
      .col-md-12
        = render   'grid'
  • <%= grid(@tasks_grid) do |g|
    
      g.column name:  'ID', attribute: 'id', filter: false
    
      g.column name:  'Title', attribute: 'title'
    
    
      g.column name:  'Priority', attribute: 'priority_id',
        custom_filter: [['NOT DEFINED', 'null'], ['DEFINED', 'not null']] + Priority.to_dropdown do |task|
        task.priority.name if task.priority
      end
    
    
      g.column   do |task|
        link_to('Edit', edit_task_path(task))
      end
    end -%>
IDTitlePriority
1-20 / 500 show all
1impedit aperiam liberoEdit
2ut sintAnecdoticEdit
3aliquam repudiandaeAnecdoticEdit
4nisi quiLowEdit
5dicta pariaturHighEdit
6molestiae autemEdit
7ut veniamHighEdit
8nullaUrgentEdit
9quisquam in isteEdit
10rerum occaecatiUrgentEdit
11aspernatur estUrgentEdit
12explicabo hicUrgentEdit
13utHighEdit
14repellat consequatur velitAnecdoticEdit
15est ut autEdit
16omnisHighEdit
17itaque suscipit commodiEdit
18necessitatibus commodiNormalEdit
19id rem eaLowEdit
20aspernatur eligendi adipisciHighEdit

Fork me on GitHub