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 -%>
IDTitleArchivedStatusProject NameDue DateAdded


1-20 / 500 show all
80corrupti officiaNoAssignedSuper Game2016-09-292015-03-12 12:37:19Edit
149omnis errorNoDuplicateSuper Game2016-07-112015-03-12 12:37:21Edit
206quia ipsum maximeNoVerifiedUltimate Website2016-01-092015-03-12 12:37:21Edit
257et nihilNoDuplicateSuper Game2016-04-142015-03-12 12:37:22Edit
269culpa assumendaNoCancelledDivine Firmware2016-06-152015-03-12 12:37:22Edit
297dolores magnam eosNoAssignedSuper Game2016-01-252015-03-12 12:37:23Edit
391aut estNoDuplicateUltimate Website2016-10-212015-03-12 12:37:24Edit
409dolore etNoPostponedUltimate Website2016-05-022015-03-12 12:37:25Edit
52eos temporibus omnisNoResolvedSuper Game2016-05-232015-03-13 12:37:19Edit
318beataeNoVerifiedDivine Firmware2016-03-192015-03-13 12:37:23Edit
83enimNoDuplicateDivine Firmware2016-10-142015-03-14 12:37:20Edit
136exercitationem distinctio quiNoCancelledDivine Firmware2016-04-012015-03-14 12:37:20Edit
233nesciunt suscipit quisYesDuplicateUltimate Website2016-05-232015-03-14 12:37:22Edit
454similique enim odioNoDuplicateDivine Firmware2016-01-112015-03-14 12:37:26Edit
462provident doloremque laudantiumNoDuplicateUltimate Website2016-01-222015-03-14 12:37:26Edit
27eum velNoResolvedUltimate Website2016-05-292015-03-15 12:37:19Edit
62eum velit saepeNoAssignedDivine Firmware2016-10-182015-03-15 12:37:19Edit
97voluptatem facilis etNoStartedDivine Firmware2016-05-262015-03-15 12:37:20Edit
390voluptas ut etNoClosedSuper Game2016-05-012015-03-15 12:37:24Edit
115sit et estNoPostponedDivine Firmware2016-08-142015-03-16 12:37:20Edit

Fork me on GitHub