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


81-100 / 449 show all
90commodi et quisCancelledDivine Firmware2016-05-302015-04-27 12:37:20
91quaeratAssignedDivine Firmware2016-06-172015-06-08 12:37:20
92est praesentiumClosedSuper Game2016-01-192015-06-08 12:37:20
93autCancelledSuper Game2016-09-202015-04-04 12:37:20
94officiisNewUltimate Website2016-02-012015-04-01 12:37:20
96impedit explicabo voluptatemVerifiedUltimate Website2016-10-252015-06-02 12:37:20
97voluptatem facilis etStartedDivine Firmware2016-05-262015-03-15 12:37:20
99solutaAssignedDivine Firmware2016-10-122015-03-25 12:37:20
100autem nonResolvedSuper Game2016-08-042015-05-02 12:37:20
101enim ullamNewDivine Firmware2016-07-122015-06-03 12:37:20
102inventore eligendi voluptasNewDivine Firmware2016-06-142015-06-11 12:37:20
103molestiaeCancelledDivine Firmware2016-04-012015-06-08 12:37:20
104autemResolvedSuper Game2016-05-232015-06-06 12:37:20
106laboriosam enimStartedDivine Firmware2016-09-122015-06-18 12:37:20
107utDuplicateDivine Firmware2016-07-292015-04-02 12:37:20
108maximeResolvedDivine Firmware2016-09-012015-05-21 12:37:20
109sit amet fugiatStartedDivine Firmware2016-02-082015-04-03 12:37:20
110hicStartedDivine Firmware2016-01-112015-05-11 12:37:20
112neque quiPostponedDivine Firmware2016-02-252015-04-05 12:37:20
113exercitationemClosedDivine Firmware2016-05-282015-04-02 12:37:20

Fork me on GitHub