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


1-20 / 449 show all
80corrupti officiaAssignedSuper Game2016-09-292015-03-12 12:37:19
149omnis errorDuplicateSuper Game2016-07-112015-03-12 12:37:21
206quia ipsum maximeVerifiedUltimate Website2016-01-092015-03-12 12:37:21
257et nihilDuplicateSuper Game2016-04-142015-03-12 12:37:22
269culpa assumendaCancelledDivine Firmware2016-06-152015-03-12 12:37:22
297dolores magnam eosAssignedSuper Game2016-01-252015-03-12 12:37:23
391aut estDuplicateUltimate Website2016-10-212015-03-12 12:37:24
409dolore etPostponedUltimate Website2016-05-022015-03-12 12:37:25
52eos temporibus omnisResolvedSuper Game2016-05-232015-03-13 12:37:19
318beataeVerifiedDivine Firmware2016-03-192015-03-13 12:37:23
83enimDuplicateDivine Firmware2016-10-142015-03-14 12:37:20
136exercitationem distinctio quiCancelledDivine Firmware2016-04-012015-03-14 12:37:20
454similique enim odioDuplicateDivine Firmware2016-01-112015-03-14 12:37:26
462provident doloremque laudantiumDuplicateUltimate Website2016-01-222015-03-14 12:37:26
27eum velResolvedUltimate Website2016-05-292015-03-15 12:37:19
62eum velit saepeAssignedDivine Firmware2016-10-182015-03-15 12:37:19
97voluptatem facilis etStartedDivine Firmware2016-05-262015-03-15 12:37:20
390voluptas ut etClosedSuper Game2016-05-012015-03-15 12:37:24
115sit et estPostponedDivine Firmware2016-08-142015-03-16 12:37:20
201voluptasNewDivine Firmware2016-05-272015-03-16 12:37:21

Fork me on GitHub