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
21-40 / 449 Sýna allt
222voluptasAnimi odio ad et nisi quod perferendis natus possimus.No2016-01-17Edit
290voluptasIste aut occaecati quo voluptates facere consequatur.No2016-01-15Edit
330voluptasSit qui aut nesciunt ut excepturi debitis id.No2016-07-15Edit
431vitae repudiandaeAliquid nihil aliquam architecto eos delectus placeat.No2016-05-21Edit
169vitae oditLaborum laboriosam odio cum ex.No2016-06-26Edit
176vitae ducimus consequunturDolores tenetur consequatur nihil minima id delectus consequatur et.No2016-05-25Edit
66vitae at autemNihil quae dolores quia ut non.No2016-06-16Edit
220vero rerumEt aliquid id sed et.No2016-03-31Edit
382vel nostrumMaiores officiis sequi aut at quia.No2016-07-19Edit
392velit vitaeVero tenetur ex et totam nam natus aperiam doloremque.No2016-08-27Edit
75velit non magniTotam dolor est sint et sed.No2016-09-16Edit
186velit dignissimosQuia et molestias quidem sit minus.No2016-07-01Edit
281velitDolorum quaerat asperiores itaque quibusdam libero aspernatur sed eius.No2016-02-14Edit
237vel esseDistinctio accusamus et dolores aliquam repudiandae omnis.No2016-10-10Edit
205velAut corrupti facere omnis officia.No2016-10-26Edit
442ut voluptatemQuibusdam et veniam ut.No2016-07-26Edit
7ut veniamMolestiae qui qui quo occaecati.No2016-08-04Edit
485ut teneturEos corporis voluptate ex sed totam.No2016-10-13Edit
2ut sintAssumenda ut in commodi nihil ratione odio voluptatibus ea.No2016-10-21Edit
440ut quae atFugiat voluptate veniam distinctio aut voluptatibus est et.No2016-05-12Edit

Fork me on GitHub