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


401-420 / 500 Sýna allt
401cum deserunt nesciuntYesAssignedUltimate Website2016-03-042015-05-18 12:37:25Edit
402atNoAssignedSuper Game2016-04-292015-06-01 12:37:25Edit
403et praesentium temporeNoVerifiedUltimate Website2016-10-202015-05-01 12:37:25Edit
404at aliquam corruptiNoAssignedSuper Game2016-01-272015-05-23 12:37:25Edit
405magni excepturiNoCancelledDivine Firmware2016-10-192015-05-31 12:37:25Edit
406sequi beataeNoResolvedUltimate Website2016-01-212015-04-26 12:37:25Edit
407similique voluptatumNoVerifiedUltimate Website2016-10-052015-05-08 12:37:25Edit
408quibusdam voluptateNoAssignedSuper Game2016-04-162015-04-10 12:37:25Edit
409dolore etNoPostponedUltimate Website2016-05-022015-03-12 12:37:25Edit
410et qui sintNoStartedDivine Firmware2016-05-142015-04-11 12:37:25Edit
411iureNoClosedDivine Firmware2016-02-232015-03-21 12:37:25Edit
412nonNoResolvedSuper Game2016-03-212015-03-17 12:37:25Edit
413voluptateNoNewSuper Game2016-03-102015-03-25 12:37:25Edit
414quo architecto nonYesPostponedUltimate Website2016-01-072015-05-19 12:37:25Edit
415voluptatemNoResolvedDivine Firmware2016-06-162015-04-17 12:37:25Edit
416ipsamYesDuplicateDivine Firmware2016-07-142015-04-28 12:37:25Edit
417provident eumNoVerifiedSuper Game2016-01-142015-05-26 12:37:25Edit
418cupiditate ut illumNoCancelledUltimate Website2016-10-242015-05-27 12:37:25Edit
419voluptatem rerumYesClosedDivine Firmware2016-01-242015-04-21 12:37:25Edit
420rem nequeNoPostponedSuper Game2016-06-142015-04-14 12:37:25Edit

Fork me on GitHub