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
    
  • .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'
    
  • <%= 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 -%>
    

IDTitleStatus Project NameDue DateAdded


1-20 / 449 show all
497impedit quoNewSuper Game2016-07-092015-04-11 12:37:27
487natus etNewUltimate Website2016-01-312015-05-14 12:37:26
477et corruptiNewSuper Game2016-06-102015-05-03 12:37:26
463excepturiNewSuper Game2016-08-222015-03-18 12:37:26
457asperiores qui nonNewDivine Firmware2016-05-162015-05-15 12:37:26
456inventore voluptasNewDivine Firmware2016-04-012015-05-31 12:37:26
455etNewUltimate Website2016-06-102015-04-14 12:37:26
448tempore aliquam rationeNewSuper Game2016-01-212015-03-23 12:37:26
445delectusNewUltimate Website2016-08-292015-05-13 12:37:26
443ullam laudantium commodiNewDivine Firmware2016-10-252015-05-18 12:37:26
442ut voluptatemNewDivine Firmware2016-07-262015-06-10 12:37:25
426accusantium eligendiNewSuper Game2016-09-012015-04-29 12:37:25
413voluptateNewSuper Game2016-03-102015-03-25 12:37:25
399rerum quaeNewUltimate Website2016-03-242015-04-16 12:37:25
398dolores sitNewDivine Firmware2016-09-202015-03-29 12:37:25
392velit vitaeNewUltimate Website2016-08-272015-05-16 12:37:24
389utNewUltimate Website2016-07-232015-05-28 12:37:24
366debitis nihil quidemNewUltimate Website2016-01-102015-05-06 12:37:24
355optioNewUltimate Website2016-05-192015-04-13 12:37:24
340est vitaeNewSuper Game2016-10-172015-06-17 12:37:23

Fork me on GitHub