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
    
  • .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'
  • <%= 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 -%>
    
IDTitle DescriptionArchivedDue Date
61-80 / 449 Alle rijen tonen
203soluta possimus estIllum ut molestiae et officia aut earum.No2016-02-20Edit
99solutaOfficiis omnis esse est debitis laboriosam.No2016-10-12Edit
115sit et estUllam dolorum dolorem placeat doloribus aut ea consequatur.No2016-08-14Edit
109sit amet fugiatVoluptatem nam dolores numquam quisquam.No2016-02-08Edit
56sitVoluptate enim perspiciatis nihil nisi necessitatibus quo dignissimos.No2016-09-10Edit
334sitVoluptatem consequatur sunt facilis debitis quia velit.No2016-09-27Edit
138sint quiCommodi qui fugiat eum aut consequuntur.No2016-03-09Edit
287sint non dolorAb aut rerum ut sequi tenetur voluptate repellat non.No2016-05-10Edit
347sint aut velDeleniti et aut laboriosam praesentium.No2016-08-12Edit
407similique voluptatumVoluptatem nesciunt quos omnis.No2016-10-05Edit
69similique placeat ipsaAlias ratione autem ut impedit non nihil itaque eaque.No2016-03-19Edit
326similique maiores esseNobis minus nam fuga quia.No2016-05-10Edit
360similique estQuas porro qui nihil libero molestias omnis pariatur.No2016-05-17Edit
454similique enim odioEa cupiditate sit ex aut laudantium voluptatem.No2016-01-11Edit
406sequi beataeSit velit consequuntur minus possimus.No2016-01-21Edit
221sequiQuo nobis aut ut dolor perferendis odit.No2016-07-04Edit
77sed quibusdam isteQuis non ducimus quia perferendis.No2016-06-18Edit
492sed atInventore ipsum qui rerum cum reiciendis nisi.No2016-06-14Edit
276sedEa provident inventore minima quis.No2016-07-18Edit
354sedQuibusdam voluptas ipsam blanditiis debitis.No2016-03-22Edit

Fork me on GitHub