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
81-100 / 449 Alle rijen tonen
387sedMolestias aut iusto aliquid.No2016-07-10Edit
356saepe illum essePerferendis ut ut quo nesciunt amet itaque.No2016-07-08Edit
256saepeEarum facere omnis voluptatem dolor ad.No2016-02-15Edit
399rerum quaeUt quisquam molestiae at aut.No2016-03-24Edit
475rerum perspiciatis eumSoluta non et temporibus.No2016-06-25Edit
10rerum occaecatiCum aperiam voluptas aut.No2016-08-14Edit
45rerumRepellat et ut eos ea illo et dolorum voluptatem.No2016-03-06Edit
157rerumEum voluptatibus quis in.No2016-04-13Edit
265reprehenderit voluptasProvident explicabo exercitationem quia voluptates.No2016-10-12Edit
369reprehenderit rerumRepudiandae assumenda reprehenderit rerum voluptatibus sapiente.No2016-01-28Edit
228reprehenderitDeleniti non necessitatibus voluptas.No2016-10-13Edit
312repellendus perferendis vitaePariatur officia maxime libero ut vel dolor delectus.No2016-08-04Edit
14repellat consequatur velitError autem et deleniti nihil maxime voluptatem eius eveniet.No2016-01-10Edit
420rem nequeExpedita voluptatibus commodi dignissimos sed voluptatum modi voluptas.No2016-06-14Edit
64reiciendisQuaerat voluptatum nihil iure.No2016-04-12Edit
190recusandae nisi doloribusPerspiciatis rerum nihil ea ipsum.No2016-10-13Edit
156rationeFugiat facilis eligendi maiores facere maxime tempora magni.No2016-10-17Edit
119quo est aliquidFugiat reprehenderit est quia ducimus voluptatem maiores tempore id.No2016-03-22Edit
213quod reprehenderitIn ex fuga voluptas dolores accusamus architecto.No2016-10-06Edit
187quodVitae voluptates voluptas et aliquam aperiam eos.No2016-06-29Edit

Fork me on GitHub