WiceGrid 3.6.0.pre4 examples

CSV export and external filters

CSV export works with define_grid and external filters, too.

  • # encoding: utf-8
    class CsvAndDetachedFiltersController < ApplicationController
      def index
        @tasks_grid = initialize_grid(Task,
          name: 'grid',
          enable_export_to_csv: true,
          csv_field_separator: ';',
          csv_file_name: 'tasks'
        )
    
        export_grid_if_requested('grid' => 'grid')
      end
    end
    
  • .well
      %h2= current_page_title
      %p
        CSV export works with
        %code define_grid
        and external filters, too.
    
    = show_code
    
    = render   'grid'
    
    
    .row
      .col-md-2
        ID:
      .col-md-10
        = grid_filter @tasks_grid, :id_filter
    
    .row
      .col-md-2
        Title:
      .col-md-10
        = grid_filter @tasks_grid, :title_filter
    
    .row
      .col-md-2
        Description:
      .col-md-10
        = grid_filter @tasks_grid, :description_filter
    
    .row
      .col-md-2
        Archived:
      .col-md-10
        = grid_filter @tasks_grid, :archived_filter
    
    
    .row
      .col-md-2
        Due date:
      .col-md-10
        = grid_filter @tasks_grid, :due_date
    
    
    .row
      .col-md-12
        %button.btn.btn-primary.wg-external-submit-button{'data-grid-name' => 'grid'} Submit
        %button.btn.btn-default.wg-external-reset-button{'data-grid-name' => 'grid'} Reset
        %button.btn.btn-primary.wg-external-csv-export-button{'data-grid-name' => 'grid'} Export To CSV
    
    %p
    
    .row
      .col-md-12
    
    
    
        = render_grid(@tasks_grid)
    
  • <%= define_grid(@tasks_grid, hide_submit_button: true, hide_reset_button: true) do |g|
    
      g.column name:  'ID', attribute: 'id', detach_with_id: :id_filter
    
      g.column name:  'Title', attribute: 'title', detach_with_id: :title_filter
    
      g.column  name:  'Description', attribute: 'description', detach_with_id: :description_filter
    
      g.column  name:  'Archived', attribute: 'archived', detach_with_id: :archived_filter do |task|
        task.archived? ? 'Yes' : 'No'
      end
    
    
      g.column name:  'Due Date', attribute: 'due_date', detach_with_id: :due_date do |task|
        task.due_date.to_s(:short)
      end
    
    
      g.column   do |task|
        link_to('Edit', edit_task_path(task))
      end
    
    end -%>
    
ID:
Title:
Description:
Archived:
Due date:

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

Fork me on GitHub