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 -%>
    
IDTitleDescriptionArchivedDue Date

1-20 / 500 Alle rijen tonen
325perferendis pariaturEst voluptas explicabo id consequatur autem et voluptatum nobis.No2016-01-06Edit
414quo architecto nonLaudantium iusto dolor facere vero provident sunt.Yes2016-01-07Edit
352autemUt provident voluptates dolor.No2016-01-08Edit
171qui est etEt temporibus sed maiores.No2016-01-08Edit
253quosAut fuga qui excepturi ut tempora dolor voluptatem.Yes2016-01-08Edit
59alias liberoRepudiandae praesentium aut nobis saepe.No2016-01-09Edit
206quia ipsum maximeEum quia expedita quo quia.No2016-01-09Edit
14repellat consequatur velitError autem et deleniti nihil maxime voluptatem eius eveniet.No2016-01-10Edit
366debitis nihil quidemMolestiae est consequatur itaque est maiores vero.No2016-01-10Edit
110hicVoluptate quia quo sed.No2016-01-11Edit
454similique enim odioEa cupiditate sit ex aut laudantium voluptatem.No2016-01-11Edit
178molestias voluptas quiIn tempora quam expedita officiis quod.No2016-01-11Edit
194quoQuis fugiat aperiam sapiente veniam provident odio inventore qui.No2016-01-12Edit
353rerum nam eligendiUt qui omnis at ducimus id non perferendis qui.Yes2016-01-12Edit
82utEt debitis enim repellat qui voluptatem a nam nisi.No2016-01-12Edit
417provident eumEos temporibus animi voluptate quia a aut vel.No2016-01-14Edit
424non autem solutaConsectetur omnis excepturi cum vitae.No2016-01-14Edit
290voluptasIste aut occaecati quo voluptates facere consequatur.No2016-01-15Edit
211et dictaExpedita tempore numquam unde ut quaerat iure est.No2016-01-17Edit
222voluptasAnimi odio ad et nisi quod perferendis natus possimus.No2016-01-17Edit

Fork me on GitHub