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


41-60 / 500 Alle rijen tonen
41estNoStartedDivine Firmware2016-04-092015-04-10 12:37:19Edit
42autNoCancelledUltimate Website2016-08-252015-04-08 12:37:19Edit
43impedit atque minimaYesVerifiedSuper Game2016-08-152015-06-03 12:37:19Edit
44id temporibus eligendiNoAssignedUltimate Website2016-03-112015-03-27 12:37:19Edit
45rerumNoPostponedDivine Firmware2016-03-062015-06-15 12:37:19Edit
46facereYesAssignedUltimate Website2016-09-212015-04-26 12:37:19Edit
47temporibus iure delectusNoCancelledUltimate Website2016-02-112015-04-22 12:37:19Edit
48qui inciduntNoCancelledDivine Firmware2016-08-022015-04-04 12:37:19Edit
49laborumNoNewUltimate Website2016-09-282015-04-30 12:37:19Edit
50ipsum nam temporeNoDuplicateSuper Game2016-03-232015-04-10 12:37:19Edit
51harum qui possimusNoCancelledDivine Firmware2016-08-242015-04-26 12:37:19Edit
52eos temporibus omnisNoResolvedSuper Game2016-05-232015-03-13 12:37:19Edit
53molestiaeNoAssignedSuper Game2016-06-042015-04-21 12:37:19Edit
54minima in voluptatemNoPostponedUltimate Website2016-10-042015-05-29 12:37:19Edit
55dolorNoCancelledSuper Game2016-04-102015-06-11 12:37:19Edit
56sitNoVerifiedSuper Game2016-09-102015-05-11 12:37:19Edit
57nequeNoPostponedDivine Firmware2016-05-242015-03-19 12:37:19Edit
58atque etNoStartedDivine Firmware2016-03-292015-05-28 12:37:19Edit
59alias liberoNoStartedUltimate Website2016-01-092015-03-23 12:37:19Edit
60voluptas repellendusNoStartedUltimate Website2016-05-022015-06-02 12:37:19Edit

Fork me on GitHub