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


341-360 / 449 show all
377quam qui quibusdamAssignedDivine Firmware2016-02-052015-03-24 12:37:24
378modi iustoDuplicateSuper Game2016-10-042015-06-16 12:37:24
380qui repellendus sintResolvedDivine Firmware2016-05-302015-05-11 12:37:24
381eosDuplicateDivine Firmware2016-05-122015-05-12 12:37:24
382vel nostrumStartedDivine Firmware2016-07-192015-06-14 12:37:24
383omnis vel delectusClosedSuper Game2016-02-172015-05-16 12:37:24
384quiaStartedDivine Firmware2016-03-122015-05-27 12:37:24
385et teneturStartedSuper Game2016-09-062015-04-13 12:37:24
386eveniet ipsam etAssignedUltimate Website2016-07-262015-03-28 12:37:24
387sedResolvedUltimate Website2016-07-102015-03-27 12:37:24
388aspernatur dolores velPostponedDivine Firmware2016-02-272015-05-26 12:37:24
389utNewUltimate Website2016-07-232015-05-28 12:37:24
390voluptas ut etClosedSuper Game2016-05-012015-03-15 12:37:24
391aut estDuplicateUltimate Website2016-10-212015-03-12 12:37:24
392velit vitaeNewUltimate Website2016-08-272015-05-16 12:37:24
394minus facilisResolvedSuper Game2016-08-042015-03-28 12:37:24
395quia nobis quidemStartedUltimate Website2016-05-232015-05-24 12:37:24
396at consequatur quaeratDuplicateSuper Game2016-02-242015-03-29 12:37:24
398dolores sitNewDivine Firmware2016-09-202015-03-29 12:37:25
399rerum quaeNewUltimate Website2016-03-242015-04-16 12:37:25

Fork me on GitHub