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
    
  • <%= 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 -%>
  • .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'
IDTitleArchived StatusProject NameDue DateAdded


481-500 / 500 Alle rijen tonen
397tempore ut aliquidYesAssignedSuper Game2016-07-012015-06-05 12:37:24Edit
421reiciendis dolorum quodYesCancelledDivine Firmware2016-05-282015-04-11 12:37:25Edit
85voluptatibus inventoreYesClosedUltimate Website2016-06-032015-06-12 12:37:20Edit
293sed est estYesCancelledUltimate Website2016-06-272015-04-22 12:37:23Edit
353rerum nam eligendiYesNewDivine Firmware2016-01-122015-04-08 12:37:24Edit
500vel eaYesStartedUltimate Website2016-03-302015-04-16 12:37:27Edit
43impedit atque minimaYesVerifiedSuper Game2016-08-152015-06-03 12:37:19Edit
271etYesResolvedDivine Firmware2016-10-112015-05-19 12:37:22Edit
296cupiditate in minimaYesVerifiedDivine Firmware2016-03-172015-05-02 12:37:23Edit
46facereYesAssignedUltimate Website2016-09-212015-04-26 12:37:19Edit
273veroYesAssignedSuper Game2016-06-132015-05-11 12:37:22Edit
244autem sintYesNewDivine Firmware2016-06-302015-04-14 12:37:22Edit
209fugaYesNewUltimate Website2016-03-012015-04-24 12:37:22Edit
444asperiores quisYesVerifiedSuper Game2016-02-292015-04-09 12:37:26Edit
95quibusdam beatae adYesVerifiedDivine Firmware2016-03-062015-05-05 12:37:20Edit
137molestiaeYesNewSuper Game2016-01-302015-06-12 12:37:20Edit
401cum deserunt nesciuntYesAssignedUltimate Website2016-03-042015-05-18 12:37:25Edit
98aperiam rerumYesClosedSuper Game2016-07-192015-05-31 12:37:20Edit
212quis veniamYesNewUltimate Website2016-09-212015-06-14 12:37:22Edit
338impeditYesAssignedDivine Firmware2016-05-062015-04-27 12:37:23Edit

Fork me on GitHub