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

461-480 / 500 show all
461dolor voluptasItaque quibusdam repellat in.No2016-06-06Edit
462provident doloremque laudantiumVoluptas nihil enim placeat.No2016-01-22Edit
463excepturiNobis doloribus eos aut voluptatem eaque.No2016-08-22Edit
464culpaError deleniti qui quaerat sint.No2016-04-17Edit
465totamQui adipisci aspernatur qui non.No2016-03-14Edit
466autIllum corporis occaecati quia quo aut ratione voluptatem.No2016-03-21Edit
467in error praesentiumEarum temporibus quae laudantium.No2016-02-04Edit
468officiisUt a qui quod saepe unde excepturi.No2016-02-28Edit
469natus autemSed deleniti iste et eos magnam delectus in sequi.Yes2016-10-08Edit
470et nonQuia eaque consequatur minima ut pariatur.No2016-07-25Edit
471illo ut evenietSed esse et sit qui iste odit sint ex.No2016-05-09Edit
472perspiciatisNihil qui dolore dignissimos dicta.No2016-03-13Edit
473voluptatum quiBlanditiis quisquam ut eos eum.No2016-03-22Edit
474possimusAut quia quia a et assumenda voluptas.No2016-06-30Edit
475rerum perspiciatis eumSoluta non et temporibus.No2016-06-25Edit
476facere voluptasOccaecati consectetur neque ullam dolores qui.Yes2016-03-14Edit
477et corruptiLabore non ab accusamus culpa aliquam dicta eaque.No2016-06-10Edit
478necessitatibusQui omnis tempora velit.No2016-03-17Edit
479provident exMolestias animi adipisci sed qui sit ducimus ut et.No2016-10-25Edit
480quas sapiente rerumQuos aut dolor error nihil at placeat quia id.No2016-07-10Edit

Fork me on GitHub