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


21-40 / 449 show all
24voluptate culpaResolvedSuper Game2016-06-242015-06-01 12:37:19
25ab quiVerifiedSuper Game2016-05-032015-05-29 12:37:19
26quia mollitia delenitiAssignedSuper Game2016-06-092015-05-23 12:37:19
27eum velResolvedUltimate Website2016-05-292015-03-15 12:37:19
28laborum enim voluptasClosedDivine Firmware2016-05-232015-05-05 12:37:19
29etResolvedUltimate Website2016-07-032015-05-01 12:37:19
30corrupti molestiae abDuplicateSuper Game2016-03-022015-04-29 12:37:19
32voluptatem ipsam liberoClosedUltimate Website2016-09-192015-06-07 12:37:19
33voluptatemResolvedUltimate Website2016-06-112015-05-04 12:37:19
34illo voluptasClosedSuper Game2016-07-022015-06-14 12:37:19
36placeatNewUltimate Website2016-05-292015-04-13 12:37:19
37etStartedUltimate Website2016-06-062015-05-09 12:37:19
38minima doloribus sedPostponedSuper Game2016-10-162015-05-08 12:37:19
39praesentium et idVerifiedSuper Game2016-03-272015-05-08 12:37:19
40dolorClosedSuper Game2016-05-142015-05-10 12:37:19
41estStartedDivine Firmware2016-04-092015-04-10 12:37:19
42autCancelledUltimate Website2016-08-252015-04-08 12:37:19
44id temporibus eligendiAssignedUltimate Website2016-03-112015-03-27 12:37:19
45rerumPostponedDivine Firmware2016-03-062015-06-15 12:37:19
47temporibus iure delectusCancelledUltimate Website2016-02-112015-04-22 12:37:19

Fork me on GitHub