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:

IDTitleDescription ArchivedDue Date
481-500 / 500 Alle rijen tonen
334sitVoluptatem consequatur sunt facilis debitis quia velit.No27 SepEdit
11aspernatur estVoluptatem error inventore officia rem nemo qui.Yes21 JunEdit
331consequuntur ipsa quiVoluptatem et quo fugiat sint dignissimos ut provident soluta.No 1 FebEdit
184minusVoluptatem harum fuga est hic fugit.No29 JunEdit
389utVoluptatem hic sapiente perspiciatis quos expedita et velit.No23 JulEdit
283quamVoluptatem id dolore non.No21 AprEdit
109sit amet fugiatVoluptatem nam dolores numquam quisquam.No 8 FebEdit
407similique voluptatumVoluptatem nesciunt quos omnis.No 5 OctEdit
166ut exVoluptatem qui aut et accusamus saepe eius laboriosam.No13 MayEdit
410et qui sintVoluptatem recusandae dicta cumque vitae.No14 MayEdit
437atVoluptatem rerum eos illo voluptatem labore autem consectetur consequatur.No29 FebEdit
295itaque velitVoluptatem rerum non expedita illum et quod.No 1 FebEdit
110hicVoluptate quia quo sed.No11 JanEdit
150qui remVoluptates deserunt non dolorem.No 2 FebEdit
449dolores sedVoluptatibus et excepturi molestiae.No31 JanEdit
487natus etVoluptatibus mollitia corporis est numquam eum.No31 JanEdit
257et nihilVoluptatibus sit et saepe eum harum et.No14 AprEdit
73iure architectoVoluptatum aperiam ad dolore aut fugit.No20 AugEdit
23exercitationem autVoluptatum aut earum at est deserunt.No21 MayEdit
374voluptatem saepeVoluptatum dicta voluptatem ut laboriosam tempora consequuntur quam.No24 MarEdit

Fork me on GitHub