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'
    

IDTitleStatusProject NameDue DateAdded


61-80 / 449 show all
69similique placeat ipsaDuplicateDivine Firmware2016-03-192015-05-08 12:37:19
70autemStartedUltimate Website2016-08-042015-03-25 12:37:19
71atResolvedSuper Game2016-07-132015-04-28 12:37:19
72illum explicabo modiVerifiedSuper Game2016-05-272015-06-16 12:37:19
73iure architectoPostponedUltimate Website2016-08-202015-04-05 12:37:19
74molestiaePostponedUltimate Website2016-03-052015-05-22 12:37:19
75velit non magniDuplicateDivine Firmware2016-09-162015-05-07 12:37:19
76totamNewUltimate Website2016-09-062015-03-31 12:37:19
77sed quibusdam isteNewDivine Firmware2016-06-182015-06-03 12:37:19
78exercitationem sapienteClosedDivine Firmware2016-06-182015-04-07 12:37:19
79animiVerifiedSuper Game2016-05-062015-05-04 12:37:19
80corrupti officiaAssignedSuper Game2016-09-292015-03-12 12:37:19
81ad quo dolorStartedDivine Firmware2016-05-182015-05-05 12:37:20
82utCancelledDivine Firmware2016-01-122015-06-04 12:37:20
83enimDuplicateDivine Firmware2016-10-142015-03-14 12:37:20
84doloreResolvedUltimate Website2016-05-282015-04-04 12:37:20
86adipisciStartedSuper Game2016-02-072015-04-08 12:37:20
87nostrumClosedDivine Firmware2016-03-312015-06-13 12:37:20
88culpaPostponedDivine Firmware2016-10-192015-05-25 12:37:20
89provident consequatur remResolvedSuper Game2016-08-202015-03-30 12:37:20

Fork me on GitHub