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
41-60 / 449 show all
159ut maioresRerum qui esse aliquid repellat eveniet nemo.No2016-01-17Edit
433ut facereSit sapiente ducimus earum quia.No2016-02-21Edit
166ut exVoluptatem qui aut et accusamus saepe eius laboriosam.No2016-05-13Edit
446ut et sitUt voluptatem est facere quasi.No2016-07-06Edit
13utEst voluptas impedit perferendis excepturi aliquid doloremque.No2016-07-18Edit
82utEt debitis enim repellat qui voluptatem a nam nisi.No2016-01-12Edit
107utInventore saepe voluptatibus voluptas dignissimos omnis molestias quisquam.No2016-07-29Edit
389utVoluptatem hic sapiente perspiciatis quos expedita et velit.No2016-07-23Edit
438undePlaceat occaecati sunt at dolor quos aspernatur rerum voluptatem.No2016-09-07Edit
443ullam laudantium commodiEaque tempora non quia sit quia perspiciatis mollitia.No2016-10-25Edit
151ullam labore architectoFugit ut deserunt quia dolorem ut.No2016-06-30Edit
76totamDistinctio et pariatur non est consequatur enim.No2016-09-06Edit
465totamQui adipisci aspernatur qui non.No2016-03-14Edit
47temporibus iure delectusCumque placeat aut vel repellat omnis accusamus error odio.No2016-02-11Edit
448tempore aliquam rationeQuam rerum tenetur aliquid.No2016-01-21Edit
181temporeCorporis rerum id possimus adipisci placeat omnis et.No2016-06-01Edit
123suscipit sunt deseruntDolores quasi minus fugiat reprehenderit et consequatur.No2016-03-20Edit
207sunt laborum cupiditateTempore laborum veniam non iure non minima.No2016-05-23Edit
235sunt ametHic similique sit cupiditate.No2016-09-26Edit
259suntEos recusandae ut provident voluptas consequatur enim.No2016-02-29Edit

Fork me on GitHub