WiceGrid 3.6.0.pre4 examples

Auto reloading filters

It is possible to reload the grid on each filter action like changing the selected option in a dropdown filter or typing in a text filter. One way to do it is to use auto_reload: true for each column. Another way is changing Wice::Defaults::AUTO_RELOAD in the WiceGrid config file.

  • # encoding: utf-8
    class AutoReloadsController < ApplicationController
      def index
        @tasks_grid = initialize_grid(Task,
          custom_order: {
            'tasks.priority_id' => 'priorities.name',
            'tasks.status_id' => 'statuses.position',
            'tasks.project_id' => 'projects.name'
          },
          order: 'id',
          order_direction: 'asc'
        )
      end
    end
    
  • .well
      %h2= current_page_title
      %p
        It is possible to reload the grid on each filter action like changing the selected option in a dropdown filter or typing in a text filter.
        One way to do it is to use
        %code auto_reload:  true
        for each column. Another way is changing
        %code Wice::Defaults::AUTO_RELOAD
        in the WiceGrid config file.
    
    = show_code
    
    .row-fluid
      .col-md-12
        = render   'grid'
  • <%= grid(@tasks_grid,  hide_submit_button: true) do |g|
    
      g.column name:  'ID', attribute: 'id', auto_reload:  true , filter_type: :range
    
      g.column name:  'Title', attribute: 'title', auto_reload:  true, negation: true
    
      g.column name:  'Archived', attribute: 'archived', auto_reload:  true do |rec|
        rec.archived? ? 'Yes' : 'No'
      end
    
    
      g.column name:  'Status', attribute: 'status_id', custom_filter: Status.to_dropdown, auto_reload:  true  do |task|
        task.status.name if task.status
      end
    
      g.column name:  'Project Name', attribute: 'project_id', custom_filter: Project.to_dropdown, auto_reload:  true do |task|
        task.project.name if task.project
      end
    
      g.column name:  'Due Date', attribute: 'due_date', auto_reload:  true do |task|
        task.due_date if task.due_date
      end
    
    
      g.column name:  'Added', attribute: 'created_at', auto_reload:  true do |task|
        task.created_at.to_s(:db)
      end
    
      g.column   do |task|
        link_to('Edit', edit_task_path(task))
      end
    end -%>
ID TitleArchivedStatusProject NameDue DateAdded


21-40 / 500 show all
21et rerum laborumNoCancelledSuper Game2016-04-292015-03-19 12:37:18Edit
22etNoCancelledSuper Game2016-08-282015-05-19 12:37:19Edit
23exercitationem autNoClosedDivine Firmware2016-05-212015-04-23 12:37:19Edit
24voluptate culpaNoResolvedSuper Game2016-06-242015-06-01 12:37:19Edit
25ab quiNoVerifiedSuper Game2016-05-032015-05-29 12:37:19Edit
26quia mollitia delenitiNoAssignedSuper Game2016-06-092015-05-23 12:37:19Edit
27eum velNoResolvedUltimate Website2016-05-292015-03-15 12:37:19Edit
28laborum enim voluptasNoClosedDivine Firmware2016-05-232015-05-05 12:37:19Edit
29etNoResolvedUltimate Website2016-07-032015-05-01 12:37:19Edit
30corrupti molestiae abNoDuplicateSuper Game2016-03-022015-04-29 12:37:19Edit
31debitis pariatur illoYesCancelledUltimate Website2016-08-292015-05-18 12:37:19Edit
32voluptatem ipsam liberoNoClosedUltimate Website2016-09-192015-06-07 12:37:19Edit
33voluptatemNoResolvedUltimate Website2016-06-112015-05-04 12:37:19Edit
34illo voluptasNoClosedSuper Game2016-07-022015-06-14 12:37:19Edit
35modiYesResolvedSuper Game2016-05-082015-06-16 12:37:19Edit
36placeatNoNewUltimate Website2016-05-292015-04-13 12:37:19Edit
37etNoStartedUltimate Website2016-06-062015-05-09 12:37:19Edit
38minima doloribus sedNoPostponedSuper Game2016-10-162015-05-08 12:37:19Edit
39praesentium et idNoVerifiedSuper Game2016-03-272015-05-08 12:37:19Edit
40dolorNoClosedSuper Game2016-05-142015-05-10 12:37:19Edit

Fork me on GitHub