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


161-180 / 449 Voir tous
176vitae ducimus consequunturClosedSuper Game2016-05-252015-04-25 12:37:21
177ex perferendis velitVerifiedUltimate Website2016-08-022015-03-18 12:37:21
178molestias voluptas quiPostponedSuper Game2016-01-112015-04-14 12:37:21
179omnis et facilisAssignedDivine Firmware2016-04-162015-03-29 12:37:21
180cupiditate tenetur omnisCancelledDivine Firmware2016-02-092015-06-17 12:37:21
181temporeNewUltimate Website2016-06-012015-05-09 12:37:21
182voluptates nullaClosedSuper Game2016-08-032015-05-22 12:37:21
183iureVerifiedUltimate Website2016-03-042015-04-14 12:37:21
184minusClosedUltimate Website2016-06-292015-04-05 12:37:21
185aspernaturStartedSuper Game2016-03-232015-04-11 12:37:21
186velit dignissimosCancelledUltimate Website2016-07-012015-04-11 12:37:21
187quodAssignedDivine Firmware2016-06-292015-03-31 12:37:21
188aliquid adipisciAssignedUltimate Website2016-08-152015-05-21 12:37:21
189delectus utStartedSuper Game2016-06-122015-05-27 12:37:21
190recusandae nisi doloribusCancelledUltimate Website2016-10-132015-03-30 12:37:21
191quis aut architectoClosedSuper Game2016-08-182015-04-30 12:37:21
192eumVerifiedUltimate Website2016-09-192015-06-19 12:37:21
193idDuplicateDivine Firmware2016-02-222015-05-15 12:37:21
194quoAssignedUltimate Website2016-01-122015-03-26 12:37:21
195nihilDuplicateSuper Game2016-08-022015-06-04 12:37:21

Fork me on GitHub