WiceGrid 3.6.0.pre4 examples

Date/Datetime helpers

WiceGrid provides four filters for selecting dates and time:

  • :jquery_datepicker - Jquery datepicker (works for datetime, too)
  • :bootstrap_datepicker - Bootstrap datepicker (works for datetime, too)
  • :rails_date_helper - standard Rails date helper
  • :rails_datetime_helper - standard Rails datetime helper
Specify a date/datetime filter just like you specify any other filter:

Default filters are defined in configuration constants Wice::Defaults::DEFAULT_FILTER_FOR_DATE and Wice::Defaults::DEFAULT_FILTER_FOR_DATETIME. By default :jquery_datepicker is used for both dates and time.

  • # encoding: utf-8
    class DatesController < ApplicationController
      def index
        @tasks_grid = initialize_grid(Task,
          order: 'id'
        )
      end
    end
    
  • .well
      %h2= current_page_title
      %p
        WiceGrid provides four filters for selecting dates and time:
    
        %ul
          %li
            %code
              \:jquery_datepicker
            \- Jquery datepicker (works for datetime, too)
    
          %li
            %code
              \:bootstrap_datepicker
            \- Bootstrap datepicker (works for datetime, too)
    
          %li
            %code
              \:rails_date_helper
            \- standard Rails date helper
    
          %li
            %code
              \:rails_datetime_helper
            \- standard Rails datetime helper
    
        Specify a date/datetime filter just like you specify any other filter:
    
    
      %p
        Default filters are defined in configuration constants
        %code
          Wice::Defaults::DEFAULT_FILTER_FOR_DATE
        and
        %code
          Wice::Defaults::DEFAULT_FILTER_FOR_DATETIME.
        By default
        %code
          \:jquery_datepicker
        is used for both dates and time.
    
    
    
    
    
    
    
    = show_code
    
    .row-fluid
      .col-md-12
        = render   'grid'
  • 
    <%= grid(@tasks_grid) do |g|
    
      g.column name:  'ID', attribute: 'id', filter: false
    
      g.column name:  'Title', attribute: 'title'
    
      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 if task.due_date
      end
    
      g.column name:  'Added', attribute: 'created_at' do |task|
        task.created_at.to_s(:db)
      end
    
      g.column name:  'Updated', attribute: 'updated_at', filter_type: :rails_datetime_helper do |task|
        task.updated_at.to_s(:db)
      end
    
    
    end -%>
IDTitleArchivedDue Date AddedUpdated


:
:
1-20 / 500 show all
325perferendis pariaturNo2016-01-062015-05-06 12:37:232015-07-15 12:37:23
414quo architecto nonYes2016-01-072015-05-19 12:37:252015-07-17 12:37:25
352autemNo2016-01-082015-06-12 12:37:242015-07-04 12:37:24
171qui est etNo2016-01-082015-04-09 12:37:212015-08-21 12:37:21
253quosYes2016-01-082015-05-26 12:37:222015-09-07 12:37:22
59alias liberoNo2016-01-092015-03-23 12:37:192015-06-22 12:37:19
206quia ipsum maximeNo2016-01-092015-03-12 12:37:212015-09-03 12:37:21
14repellat consequatur velitNo2016-01-102015-05-06 12:37:182015-06-27 12:37:18
366debitis nihil quidemNo2016-01-102015-05-06 12:37:242015-08-05 12:37:24
110hicNo2016-01-112015-05-11 12:37:202015-09-12 12:37:20
454similique enim odioNo2016-01-112015-03-14 12:37:262015-08-30 12:37:26
178molestias voluptas quiNo2016-01-112015-04-14 12:37:212015-08-14 12:37:21
194quoNo2016-01-122015-03-26 12:37:212015-09-03 12:37:21
353rerum nam eligendiYes2016-01-122015-04-08 12:37:242015-09-17 12:37:24
82utNo2016-01-122015-06-04 12:37:202015-06-27 12:37:20
417provident eumNo2016-01-142015-05-26 12:37:252015-09-01 12:37:25
424non autem solutaNo2016-01-142015-06-01 12:37:252015-06-24 12:37:25
290voluptasNo2016-01-152015-06-02 12:37:232015-06-26 12:37:23
211et dictaNo2016-01-172015-04-22 12:37:222015-06-27 12:37:22
222voluptasNo2016-01-172015-06-04 12:37:222015-09-20 12:37:22

Fork me on GitHub