WiceGrid 3.6.0.pre4 examples

Initial conditions and ordering

Use :order and :order_direction in initialize_grid to define by which column the grid should be ordered once it is loaded initially.

Use :conditions in initialize_grid to define the subset of records shown in the grid.

  • # encoding: utf-8
    class Basics6Controller < ApplicationController
      def index
        @tasks_grid = initialize_grid(Task,
          order: 'tasks.title',
          order_direction: 'desc',
          conditions: { archived: false },
          per_page: 20
        )
      end
    end
    
  • <%= grid(@tasks_grid) do |g|
    
      g.column name:  'ID', attribute: 'id', filter: false
    
      g.column name:  'Title', attribute: 'title'
    
      g.column  name:  'Description', attribute: 'description'
    
      g.column  name:  'Archived', attribute: 'archived' do |task|
        task.archived? ? 'Yes' : 'No'
      end
    
      g.column name:  'Due Date', attribute: 'due_date', filter: false
    
    
      g.column   do |task|
        link_to('Edit', edit_task_path(task))
      end
    end -%>
    
  • .well
      %h2= current_page_title
      %p
        Use
        %code :order
        and
        %code :order_direction
        in
        %code  initialize_grid
        to define by which column the grid should be ordered once it is loaded initially.
    
      %p
        Use
        %code :conditions
        in
        %code  initialize_grid
        to define the subset of records shown in the grid.
    
    = show_code
    
    .row-fluid
      .col-md-12
        = render   'grid'
IDTitleDescriptionArchivedDue Date
1-20 / 449 show all
325perferendis pariaturEst voluptas explicabo id consequatur autem et voluptatum nobis.No2016-01-06Edit
171qui est etEt temporibus sed maiores.No2016-01-08Edit
352autemUt provident voluptates dolor.No2016-01-08Edit
59alias liberoRepudiandae praesentium aut nobis saepe.No2016-01-09Edit
206quia ipsum maximeEum quia expedita quo quia.No2016-01-09Edit
14repellat consequatur velitError autem et deleniti nihil maxime voluptatem eius eveniet.No2016-01-10Edit
366debitis nihil quidemMolestiae est consequatur itaque est maiores vero.No2016-01-10Edit
178molestias voluptas quiIn tempora quam expedita officiis quod.No2016-01-11Edit
110hicVoluptate quia quo sed.No2016-01-11Edit
454similique enim odioEa cupiditate sit ex aut laudantium voluptatem.No2016-01-11Edit
194quoQuis fugiat aperiam sapiente veniam provident odio inventore qui.No2016-01-12Edit
82utEt debitis enim repellat qui voluptatem a nam nisi.No2016-01-12Edit
417provident eumEos temporibus animi voluptate quia a aut vel.No2016-01-14Edit
424non autem solutaConsectetur omnis excepturi cum vitae.No2016-01-14Edit
290voluptasIste aut occaecati quo voluptates facere consequatur.No2016-01-15Edit
159ut maioresRerum qui esse aliquid repellat eveniet nemo.No2016-01-17Edit
222voluptasAnimi odio ad et nisi quod perferendis natus possimus.No2016-01-17Edit
211et dictaExpedita tempore numquam unde ut quaerat iure est.No2016-01-17Edit
92est praesentiumModi pariatur voluptatem perspiciatis.No2016-01-19Edit
448tempore aliquam rationeQuam rerum tenetur aliquid.No2016-01-21Edit

Fork me on GitHub