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 -%>
IDTitle ArchivedStatusProject NameDue DateAdded


1-20 / 500 show all
25ab quiNoVerifiedSuper Game2016-05-032015-05-29 12:37:19Edit
63accusamusNoNewSuper Game2016-09-172015-04-15 12:37:19Edit
436accusantiumNoAssignedSuper Game2016-10-012015-04-05 12:37:25Edit
426accusantium eligendiNoNewSuper Game2016-09-012015-04-29 12:37:25Edit
370accusantium error exercitationemNoClosedDivine Firmware2016-01-242015-04-25 12:37:24Edit
168adNoClosedUltimate Website2016-10-062015-04-25 12:37:21Edit
86adipisciNoStartedSuper Game2016-02-072015-04-08 12:37:20Edit
346adipisci at nesciuntNoStartedDivine Firmware2016-10-142015-06-18 12:37:24Edit
146adipisci etYesAssignedUltimate Website2016-03-012015-04-06 12:37:21Edit
147adipisci ut asperioresNoNewSuper Game2016-08-242015-03-29 12:37:21Edit
81ad quo dolorNoStartedDivine Firmware2016-05-182015-05-05 12:37:20Edit
59alias liberoNoStartedUltimate Website2016-01-092015-03-23 12:37:19Edit
3aliquam repudiandaeNoAssignedDivine Firmware2016-04-202015-03-21 12:37:18Edit
188aliquid adipisciNoAssignedUltimate Website2016-08-152015-05-21 12:37:21Edit
139aliquid oditNoDuplicateDivine Firmware2016-10-112015-04-19 12:37:20Edit
230aliquid rerum modiYesCancelledUltimate Website2016-07-202015-04-23 12:37:22Edit
215aliquid sed suntYesDuplicateSuper Game2016-07-292015-05-12 12:37:22Edit
79animiNoVerifiedSuper Game2016-05-062015-05-04 12:37:19Edit
447animi accusantium utNoClosedDivine Firmware2016-10-152015-04-06 12:37:26Edit
175aperiam omnisNoCancelledUltimate Website2016-04-172015-05-02 12:37:21Edit

Fork me on GitHub