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'
IDTitle DescriptionArchivedDue Date
421-440 / 449 Voir tous
396at consequatur quaeratNostrum enim iusto architecto numquam.No2016-02-24Edit
404at aliquam corruptiVitae ut excepturi earum eum officia quidem repellat perspiciatis.No2016-01-27Edit
402atReiciendis ut reprehenderit occaecati quia voluptatum error debitis.No2016-04-29Edit
437atVoluptatem rerum eos illo voluptatem labore autem consectetur consequatur.No2016-02-29Edit
71atRatione distinctio eligendi quaerat.No2016-07-13Edit
376assumendaBlanditiis tempora qui ut ex.No2016-09-25Edit
20aspernatur eligendi adipisciMaiores perspiciatis tempore et aut sapiente eaque.No2016-06-08Edit
388aspernatur dolores velIn velit quis optio exercitationem aspernatur et pariatur.No2016-02-27Edit
185aspernaturAutem minus et libero inventore.No2016-03-23Edit
457asperiores qui nonIllum consequatur laboriosam iusto praesentium sed dolore.No2016-05-16Edit
145asperioresSit consectetur dignissimos blanditiis velit aperiam est ratione reprehenderit.No2016-10-08Edit
309architecto esse autNisi quam et amet dolorem in assumenda.No2016-02-12Edit
175aperiam omnisNisi qui itaque quia quaerat.No2016-04-17Edit
447animi accusantium utSequi dolorem distinctio sit doloremque et corporis voluptatem alias.No2016-10-15Edit
79animiCorporis est inventore nesciunt est nam voluptas et.No2016-05-06Edit
139aliquid oditOccaecati veritatis asperiores vitae aut.No2016-10-11Edit
188aliquid adipisciEaque maxime mollitia in vel.No2016-08-15Edit
3aliquam repudiandaeConsequatur iste similique dolorum ducimus ut.No2016-04-20Edit
59alias liberoRepudiandae praesentium aut nobis saepe.No2016-01-09Edit
81ad quo dolorTempora culpa laborum et illum suscipit facilis earum et.No2016-05-18Edit

Fork me on GitHub