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
41-60 / 500 show all
41estIpsum illo corrupti nesciunt facere.No 9 AprEdit
42autEt eaque dignissimos magnam.No25 AugEdit
43impedit atque minimaAperiam expedita autem porro enim veniam.Yes15 AugEdit
44id temporibus eligendiId dignissimos dolorem enim ut.No11 MarEdit
45rerumRepellat et ut eos ea illo et dolorum voluptatem.No 6 MarEdit
46facereEst nesciunt molestiae labore ut.Yes21 SepEdit
47temporibus iure delectusCumque placeat aut vel repellat omnis accusamus error odio.No11 FebEdit
48qui inciduntDignissimos harum ut ea veritatis ut.No 2 AugEdit
49laborumFacere perferendis sapiente atque.No28 SepEdit
50ipsum nam temporeBlanditiis totam ab aut.No23 MarEdit
51harum qui possimusNemo odio id ut quam praesentium esse.No24 AugEdit
52eos temporibus omnisSapiente accusamus recusandae sunt animi voluptates dolorem enim.No23 MayEdit
53molestiaeConsequatur explicabo quos unde esse a distinctio sapiente voluptas.No 4 JunEdit
54minima in voluptatemFacilis vitae et voluptatem similique quas dolore ipsam.No 4 OctEdit
55dolorError odio possimus labore.No10 AprEdit
56sitVoluptate enim perspiciatis nihil nisi necessitatibus quo dignissimos.No10 SepEdit
57nequeNisi mollitia ipsam autem est voluptas consequatur expedita.No24 MayEdit
58atque etEst alias est non debitis omnis voluptatem.No29 MarEdit
59alias liberoRepudiandae praesentium aut nobis saepe.No 9 JanEdit
60voluptas repellendusTempora suscipit quibusdam rerum expedita aut.No 2 MayEdit

Fork me on GitHub