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


1-20 / 500 Alle rijen tonen
1impedit aperiam liberoNoCancelledDivine Firmware2016-07-272015-05-22 12:37:18Edit
2ut sintNoAssignedDivine Firmware2016-10-212015-04-09 12:37:18Edit
3aliquam repudiandaeNoAssignedDivine Firmware2016-04-202015-03-21 12:37:18Edit
4nisi quiNoVerifiedDivine Firmware2016-05-162015-03-18 12:37:18Edit
5dicta pariaturNoPostponedDivine Firmware2016-03-042015-04-19 12:37:18Edit
6molestiae autemYesResolvedUltimate Website2016-10-262015-05-16 12:37:18Edit
7ut veniamNoPostponedUltimate Website2016-08-042015-05-10 12:37:18Edit
8nullaNoResolvedDivine Firmware2016-05-222015-04-25 12:37:18Edit
9quisquam in isteNoDuplicateUltimate Website2016-03-072015-06-07 12:37:18Edit
10rerum occaecatiNoCancelledSuper Game2016-08-142015-05-22 12:37:18Edit
11aspernatur estYesStartedSuper Game2016-06-212015-03-24 12:37:18Edit
12explicabo hicNoPostponedDivine Firmware2016-04-152015-05-26 12:37:18Edit
13utNoClosedUltimate Website2016-07-182015-03-22 12:37:18Edit
14repellat consequatur velitNoNewUltimate Website2016-01-102015-05-06 12:37:18Edit
15est ut autNoNewDivine Firmware2016-10-302015-04-17 12:37:18Edit
16omnisNoAssignedSuper Game2016-02-052015-03-21 12:37:18Edit
17itaque suscipit commodiNoStartedSuper Game2016-08-232015-03-30 12:37:18Edit
18necessitatibus commodiNoStartedSuper Game2016-03-282015-03-27 12:37:18Edit
19id rem eaYesVerifiedSuper Game2016-04-142015-03-29 12:37:18Edit
20aspernatur eligendi adipisciNoAssignedUltimate Website2016-06-082015-05-30 12:37:18Edit

Fork me on GitHub