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

IDTitle StatusProject NameDue DateAdded


1-20 / 449 show all
25ab quiVerifiedSuper Game2016-05-032015-05-29 12:37:19
63accusamusNewSuper Game2016-09-172015-04-15 12:37:19
436accusantiumAssignedSuper Game2016-10-012015-04-05 12:37:25
426accusantium eligendiNewSuper Game2016-09-012015-04-29 12:37:25
370accusantium error exercitationemClosedDivine Firmware2016-01-242015-04-25 12:37:24
168adClosedUltimate Website2016-10-062015-04-25 12:37:21
86adipisciStartedSuper Game2016-02-072015-04-08 12:37:20
346adipisci at nesciuntStartedDivine Firmware2016-10-142015-06-18 12:37:24
147adipisci ut asperioresNewSuper Game2016-08-242015-03-29 12:37:21
81ad quo dolorStartedDivine Firmware2016-05-182015-05-05 12:37:20
59alias liberoStartedUltimate Website2016-01-092015-03-23 12:37:19
3aliquam repudiandaeAssignedDivine Firmware2016-04-202015-03-21 12:37:18
188aliquid adipisciAssignedUltimate Website2016-08-152015-05-21 12:37:21
139aliquid oditDuplicateDivine Firmware2016-10-112015-04-19 12:37:20
79animiVerifiedSuper Game2016-05-062015-05-04 12:37:19
447animi accusantium utClosedDivine Firmware2016-10-152015-04-06 12:37:26
175aperiam omnisCancelledUltimate Website2016-04-172015-05-02 12:37:21
309architecto esse autVerifiedUltimate Website2016-02-122015-05-25 12:37:23
145asperioresAssignedSuper Game2016-10-082015-06-05 12:37:20
457asperiores qui nonNewDivine Firmware2016-05-162015-05-15 12:37:26

Fork me on GitHub