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

41-60 / 500 Sýna allt
41estIpsum illo corrupti nesciunt facere.No2016-04-09Edit
42autEt eaque dignissimos magnam.No2016-08-25Edit
43impedit atque minimaAperiam expedita autem porro enim veniam.Yes2016-08-15Edit
44id temporibus eligendiId dignissimos dolorem enim ut.No2016-03-11Edit
45rerumRepellat et ut eos ea illo et dolorum voluptatem.No2016-03-06Edit
46facereEst nesciunt molestiae labore ut.Yes2016-09-21Edit
47temporibus iure delectusCumque placeat aut vel repellat omnis accusamus error odio.No2016-02-11Edit
48qui inciduntDignissimos harum ut ea veritatis ut.No2016-08-02Edit
49laborumFacere perferendis sapiente atque.No2016-09-28Edit
50ipsum nam temporeBlanditiis totam ab aut.No2016-03-23Edit
51harum qui possimusNemo odio id ut quam praesentium esse.No2016-08-24Edit
52eos temporibus omnisSapiente accusamus recusandae sunt animi voluptates dolorem enim.No2016-05-23Edit
53molestiaeConsequatur explicabo quos unde esse a distinctio sapiente voluptas.No2016-06-04Edit
54minima in voluptatemFacilis vitae et voluptatem similique quas dolore ipsam.No2016-10-04Edit
55dolorError odio possimus labore.No2016-04-10Edit
56sitVoluptate enim perspiciatis nihil nisi necessitatibus quo dignissimos.No2016-09-10Edit
57nequeNisi mollitia ipsam autem est voluptas consequatur expedita.No2016-05-24Edit
58atque etEst alias est non debitis omnis voluptatem.No2016-03-29Edit
59alias liberoRepudiandae praesentium aut nobis saepe.No2016-01-09Edit
60voluptas repellendusTempora suscipit quibusdam rerum expedita aut.No2016-05-02Edit

Fork me on GitHub