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


141-160 / 449 show all
156rationePostponedSuper Game2016-10-172015-06-14 12:37:21
157rerumAssignedSuper Game2016-04-132015-06-12 12:37:21
158aut voluptatibus autAssignedSuper Game2016-08-192015-04-12 12:37:21
159ut maioresCancelledSuper Game2016-01-172015-05-09 12:37:21
160aut voluptatesDuplicateDivine Firmware2016-04-142015-03-20 12:37:21
161autVerifiedUltimate Website2016-04-252015-06-19 12:37:21
162quia nihil laboreDuplicateUltimate Website2016-03-192015-04-19 12:37:21
163ipsa quoClosedDivine Firmware2016-09-132015-04-11 12:37:21
164beatae consecteturVerifiedDivine Firmware2016-02-292015-06-07 12:37:21
165expeditaResolvedUltimate Website2016-02-132015-05-12 12:37:21
166ut exResolvedSuper Game2016-05-132015-05-06 12:37:21
167enimNewUltimate Website2016-03-012015-03-28 12:37:21
168adClosedUltimate Website2016-10-062015-04-25 12:37:21
169vitae oditVerifiedSuper Game2016-06-262015-06-07 12:37:21
170fugiatStartedUltimate Website2016-03-312015-04-20 12:37:21
171qui est etAssignedUltimate Website2016-01-082015-04-09 12:37:21
172nihil ipsamPostponedDivine Firmware2016-04-082015-04-22 12:37:21
173etAssignedSuper Game2016-02-122015-03-29 12:37:21
174ipsa quia voluptasPostponedDivine Firmware2016-07-042015-04-18 12:37:21
175aperiam omnisCancelledUltimate Website2016-04-172015-05-02 12:37:21

Fork me on GitHub