WiceGrid 3.6.0.pre4 examples

Integration with other forms

In addition to including a grid into a form it is possible to dump the state of filters into another form as a set of hidden parameters with helper dump_filter_parameters_as_hidden_fields(grid_object) .

  • # encoding: utf-8
    class IntegrationWithFormsController < ApplicationController
      def index
        @archived = params[:archived] == '1' ? true : false
    
        @tasks_grid = initialize_grid(Task,
          conditions: { archived: @archived },
          name: 'g'
        )
      end
    end
    
  • <%= grid(@tasks_grid) do |g|
    
      g.column name:  'ID', attribute: 'id', filter_type: :range
    
      g.column name:  'Title', attribute: 'title', negation: true
    
      g.column name:  'Status', attribute: 'status_id', custom_filter: Status.to_dropdown  do |task|
        task.status.name if task.status
      end
    
      g.column name:  'Project Name', attribute: 'project_id', custom_filter: Project.to_dropdown do |task|
        task.project.name if task.project
      end
    
      g.column name:  'Due Date', attribute: 'due_date' do |task|
        task.due_date if task.due_date
      end
    
      g.column name:  'Added', attribute: 'created_at' do |task|
        task.created_at.to_s(:db)
      end
    
    end -%>
    
  • .well
      %h2= current_page_title
      %p
        In addition to including
        %a{href:  action_column_index_path}a grid into a form
        it is possible to dump the state of filters into another form as a set of hidden parameters with helper
        %code dump_filter_parameters_as_hidden_fields(grid_object)
        \.
    
    = show_code
    
    = form_tag(integration_with_forms_path, method:  :get) do
      = dump_filter_parameters_as_hidden_fields(@tasks_grid)
    
      %p= select_tag 'archived', options_for_select([['View active tasks', 0], ['View archived tasks', 1]], @archived ? 1 : 0), class: 'reload-on-change form-control'
    
    
    = render   'grid'
    

ID TitleStatusProject NameDue DateAdded


1-20 / 449 Alle rijen tonen
1impedit aperiam liberoCancelledDivine Firmware2016-07-272015-05-22 12:37:18
2ut sintAssignedDivine Firmware2016-10-212015-04-09 12:37:18
3aliquam repudiandaeAssignedDivine Firmware2016-04-202015-03-21 12:37:18
4nisi quiVerifiedDivine Firmware2016-05-162015-03-18 12:37:18
5dicta pariaturPostponedDivine Firmware2016-03-042015-04-19 12:37:18
7ut veniamPostponedUltimate Website2016-08-042015-05-10 12:37:18
8nullaResolvedDivine Firmware2016-05-222015-04-25 12:37:18
9quisquam in isteDuplicateUltimate Website2016-03-072015-06-07 12:37:18
10rerum occaecatiCancelledSuper Game2016-08-142015-05-22 12:37:18
12explicabo hicPostponedDivine Firmware2016-04-152015-05-26 12:37:18
13utClosedUltimate Website2016-07-182015-03-22 12:37:18
14repellat consequatur velitNewUltimate Website2016-01-102015-05-06 12:37:18
15est ut autNewDivine Firmware2016-10-302015-04-17 12:37:18
16omnisAssignedSuper Game2016-02-052015-03-21 12:37:18
17itaque suscipit commodiStartedSuper Game2016-08-232015-03-30 12:37:18
18necessitatibus commodiStartedSuper Game2016-03-282015-03-27 12:37:18
20aspernatur eligendi adipisciAssignedUltimate Website2016-06-082015-05-30 12:37:18
21et rerum laborumCancelledSuper Game2016-04-292015-03-19 12:37:18
22etCancelledSuper Game2016-08-282015-05-19 12:37:19
23exercitationem autClosedDivine Firmware2016-05-212015-04-23 12:37:19

Fork me on GitHub