WiceGrid 3.6.0.pre4 examples

Associating columns with database fields

Once a grid column is associated with the inderlying database field with the help of the attrubute parameter the column becomes sortable and a column filter is rendered. The column filter is generated based on the type of the database field.

  • # encoding: utf-8
    class Basics3Controller < ApplicationController
      def index
        @tasks_grid = initialize_grid(Task, order: 'id')
      end
    end
    
  • <%# show_filters: :when_filtered %>
    <%= grid(@tasks_grid) do |g|
    
      g.column name:  'ID', attribute: 'id' do |task|
        task.id
      end
    
      g.column name:  'Title', attribute: 'title'  do |task|
        task.title
      end
    
      g.column  name:  'Description', attribute: 'description' do |task|
        task.description
      end
    
      g.column  name:  'Archived', attribute: 'archived' do |task|
        task.archived? ? 'Yes' : 'No'
      end
    
      g.column name:  'Due Date', attribute: 'due_date' do |task|
        task.due_date
      end
    
    
      g.column   do |task|
        link_to('Edit', edit_task_path(task))
      end
    end -%>
    
  • .well
      %h2= current_page_title
      %p
        Once a grid column is associated with the inderlying database field with the help of the
        %code attrubute
        parameter the column becomes sortable and a column filter is rendered. The column filter
        is generated based on the type of the database field.
    
    = show_code
    
    .row-fluid
      .col-md-12
        = render   'grid'
IDTitleDescription ArchivedDue Date

1-20 / 500 show all
209fugaA amet qui quas aliquam neque.Yes2016-03-01Edit
287sint non dolorAb aut rerum ut sequi tenetur voluptate repellat non.No2016-05-10Edit
204error earum quiAb labore rerum quisquam rerum enim magni.No2016-08-28Edit
429ipsamAccusamus a vel suscipit facere officia doloribus.No2016-03-17Edit
403et praesentium temporeAccusamus omnis odit in cumque soluta aliquam.No2016-10-20Edit
452illum et voluptatemAccusamus quis quis sapiente distinctio aut et quaerat asperiores.Yes2016-02-03Edit
294fugiat evenietAccusamus ut et nesciunt sit corrupti.No2016-06-10Edit
415voluptatemAccusantium mollitia dolorem nesciunt ipsa libero dolor.No2016-06-16Edit
74molestiaeAd dolores occaecati fuga ratione praesentium quo.No2016-03-05Edit
69similique placeat ipsaAlias ratione autem ut impedit non nihil itaque eaque.No2016-03-19Edit
336aut quis aspernaturAliquam fuga similique facilis accusamus reprehenderit.No2016-04-21Edit
130esse rationeAliquid dolore aut magnam voluptatum ad.No2016-04-14Edit
431vitae repudiandaeAliquid nihil aliquam architecto eos delectus placeat.No2016-05-21Edit
321quis est autemAmet veniam quia molestias eum modi impedit rerum ad.No2016-03-09Edit
413voluptateAnimi esse amet nihil ad nobis voluptatum.No2016-03-10Edit
222voluptasAnimi odio ad et nisi quod perferendis natus possimus.No2016-01-17Edit
35modiAnimi quod iste sunt.Yes2016-05-08Edit
43impedit atque minimaAperiam expedita autem porro enim veniam.Yes2016-08-15Edit
137molestiaeArchitecto praesentium ut dolorem illo facere rerum numquam provident.Yes2016-01-30Edit
229omnis commodiArchitecto qui voluptatum vel et.No2016-04-26Edit

Fork me on GitHub