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 -%>
    

IDTitleStatusProject NameDue Date Added


1-20 / 449 Alle rijen tonen
325perferendis pariaturClosedSuper Game2016-01-062015-05-06 12:37:23
171qui est etAssignedUltimate Website2016-01-082015-04-09 12:37:21
352autemPostponedSuper Game2016-01-082015-06-12 12:37:24
59alias liberoStartedUltimate Website2016-01-092015-03-23 12:37:19
206quia ipsum maximeVerifiedUltimate Website2016-01-092015-03-12 12:37:21
14repellat consequatur velitNewUltimate Website2016-01-102015-05-06 12:37:18
366debitis nihil quidemNewUltimate Website2016-01-102015-05-06 12:37:24
178molestias voluptas quiPostponedSuper Game2016-01-112015-04-14 12:37:21
110hicStartedDivine Firmware2016-01-112015-05-11 12:37:20
454similique enim odioDuplicateDivine Firmware2016-01-112015-03-14 12:37:26
194quoAssignedUltimate Website2016-01-122015-03-26 12:37:21
82utCancelledDivine Firmware2016-01-122015-06-04 12:37:20
417provident eumVerifiedSuper Game2016-01-142015-05-26 12:37:25
424non autem solutaDuplicateDivine Firmware2016-01-142015-06-01 12:37:25
290voluptasDuplicateDivine Firmware2016-01-152015-06-02 12:37:23
159ut maioresCancelledSuper Game2016-01-172015-05-09 12:37:21
222voluptasPostponedSuper Game2016-01-172015-06-04 12:37:22
211et dictaDuplicateUltimate Website2016-01-172015-04-22 12:37:22
92est praesentiumClosedSuper Game2016-01-192015-06-08 12:37:20
448tempore aliquam rationeNewSuper Game2016-01-212015-03-23 12:37:26

Fork me on GitHub