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


41-60 / 449 show all
48qui inciduntCancelledDivine Firmware2016-08-022015-04-04 12:37:19
49laborumNewUltimate Website2016-09-282015-04-30 12:37:19
50ipsum nam temporeDuplicateSuper Game2016-03-232015-04-10 12:37:19
51harum qui possimusCancelledDivine Firmware2016-08-242015-04-26 12:37:19
52eos temporibus omnisResolvedSuper Game2016-05-232015-03-13 12:37:19
53molestiaeAssignedSuper Game2016-06-042015-04-21 12:37:19
54minima in voluptatemPostponedUltimate Website2016-10-042015-05-29 12:37:19
55dolorCancelledSuper Game2016-04-102015-06-11 12:37:19
56sitVerifiedSuper Game2016-09-102015-05-11 12:37:19
57nequePostponedDivine Firmware2016-05-242015-03-19 12:37:19
58atque etStartedDivine Firmware2016-03-292015-05-28 12:37:19
59alias liberoStartedUltimate Website2016-01-092015-03-23 12:37:19
60voluptas repellendusStartedUltimate Website2016-05-022015-06-02 12:37:19
61quia architectoAssignedDivine Firmware2016-08-022015-05-15 12:37:19
62eum velit saepeAssignedDivine Firmware2016-10-182015-03-15 12:37:19
63accusamusNewSuper Game2016-09-172015-04-15 12:37:19
64reiciendisNewSuper Game2016-04-122015-03-30 12:37:19
66vitae at autemPostponedSuper Game2016-06-162015-05-06 12:37:19
67officia quo maioresCancelledSuper Game2016-10-052015-06-15 12:37:19
68exercitationem delectusPostponedDivine Firmware2016-10-012015-05-12 12:37:19

Fork me on GitHub