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


381-400 / 449 show all
425nulla quoPostponedSuper Game2016-04-302015-03-24 12:37:25
426accusantium eligendiNewSuper Game2016-09-012015-04-29 12:37:25
427quae assumendaCancelledDivine Firmware2016-10-092015-05-15 12:37:25
428commodi omnis temporeResolvedUltimate Website2016-10-052015-03-18 12:37:25
429ipsamDuplicateUltimate Website2016-03-172015-04-30 12:37:25
430enim itaqueDuplicateUltimate Website2016-07-252015-05-11 12:37:25
431vitae repudiandaeStartedSuper Game2016-05-212015-05-30 12:37:25
432magni temporeStartedUltimate Website2016-04-172015-03-26 12:37:25
433ut facereAssignedUltimate Website2016-02-212015-05-15 12:37:25
434voluptas quisquamAssignedSuper Game2016-09-162015-04-20 12:37:25
435eos deseruntCancelledDivine Firmware2016-05-272015-04-20 12:37:25
436accusantiumAssignedSuper Game2016-10-012015-04-05 12:37:25
437atResolvedUltimate Website2016-02-292015-06-03 12:37:25
438undeDuplicateUltimate Website2016-09-072015-04-26 12:37:25
439namVerifiedDivine Firmware2016-05-292015-05-23 12:37:25
440ut quae atStartedUltimate Website2016-05-122015-04-29 12:37:25
441in autStartedSuper Game2016-08-252015-05-23 12:37:25
442ut voluptatemNewDivine Firmware2016-07-262015-06-10 12:37:25
443ullam laudantium commodiNewDivine Firmware2016-10-252015-05-18 12:37:26
445delectusNewUltimate Website2016-08-292015-05-13 12:37:26

Fork me on GitHub