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
    
  • .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'
  • <%# 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 -%>
    
ID TitleDescriptionArchivedDue Date

61-80 / 500 show all
61quia architectoRerum sit aliquid quia corrupti praesentium.No2016-08-02Edit
62eum velit saepeVoluptas voluptas nesciunt in eos eum inventore.No2016-10-18Edit
63accusamusPraesentium quod ipsum error odit.No2016-09-17Edit
64reiciendisQuaerat voluptatum nihil iure.No2016-04-12Edit
65eosOccaecati atque assumenda qui deleniti.Yes2016-07-31Edit
66vitae at autemNihil quae dolores quia ut non.No2016-06-16Edit
67officia quo maioresAut aperiam aut sint voluptas voluptatibus ut cumque id.No2016-10-05Edit
68exercitationem delectusSapiente ipsa dolorem aut sed cumque in esse.No2016-10-01Edit
69similique placeat ipsaAlias ratione autem ut impedit non nihil itaque eaque.No2016-03-19Edit
70autemSit ipsa aut qui quia voluptatem omnis.No2016-08-04Edit
71atRatione distinctio eligendi quaerat.No2016-07-13Edit
72illum explicabo modiNesciunt exercitationem quisquam commodi ut.No2016-05-27Edit
73iure architectoVoluptatum aperiam ad dolore aut fugit.No2016-08-20Edit
74molestiaeAd dolores occaecati fuga ratione praesentium quo.No2016-03-05Edit
75velit non magniTotam dolor est sint et sed.No2016-09-16Edit
76totamDistinctio et pariatur non est consequatur enim.No2016-09-06Edit
77sed quibusdam isteQuis non ducimus quia perferendis.No2016-06-18Edit
78exercitationem sapienteQuasi numquam aut magnam expedita dolor repudiandae officiis.No2016-06-18Edit
79animiCorporis est inventore nesciunt est nam voluptas et.No2016-05-06Edit
80corrupti officiaDolore odit consequatur dolores quia deleniti veniam.No2016-09-29Edit

Fork me on GitHub