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
1-20 / 449 Sýna allt
473voluptatum quiBlanditiis quisquam ut eos eum.No2016-03-22Edit
275voluptatumEsse magnam ut repellendus.No2016-06-21Edit
304voluptatibus minimaEa exercitationem molestiae magni corrupti quis aperiam et repellat.No2016-09-24Edit
182voluptates nullaUllam est et quisquam perspiciatis qui aliquid neque dolores.No2016-08-03Edit
129voluptates minima molestiaeMolestias enim voluptatibus voluptatem aut.No2016-10-16Edit
260voluptates dolorem officiaSint quidem vel asperiores.No2016-08-29Edit
374voluptatem saepeVoluptatum dicta voluptatem ut laboriosam tempora consequuntur quam.No2016-03-24Edit
32voluptatem ipsam liberoBlanditiis omnis enim voluptas fugit molestiae.No2016-09-19Edit
97voluptatem facilis etIncidunt dolorem molestias deserunt repellat vero aut.No2016-05-26Edit
33voluptatemDolorem saepe et aspernatur.No2016-06-11Edit
415voluptatemAccusantium mollitia dolorem nesciunt ipsa libero dolor.No2016-06-16Edit
489voluptatemExcepturi voluptas molestias aspernatur corporis.No2016-01-31Edit
499voluptatemMagnam accusantium id aut et quaerat praesentium eveniet.No2016-06-19Edit
24voluptate culpaEt velit ut libero dolores.No2016-06-24Edit
413voluptateAnimi esse amet nihil ad nobis voluptatum.No2016-03-10Edit
390voluptas ut etEst eos omnis doloremque aut.No2016-05-01Edit
60voluptas repellendusTempora suscipit quibusdam rerum expedita aut.No2016-05-02Edit
434voluptas quisquamRerum quaerat eos numquam.No2016-09-16Edit
128voluptasEst cum porro et et.No2016-05-31Edit
201voluptasEt ut autem at ex voluptatibus assumenda.No2016-05-27Edit

Fork me on GitHub