WiceGrid 3.6.0.pre4 examples

Hiding certain checkboxes in the action column

You can hide a certain action checkbox if you add the usual block to g.action_column , just like with the g.column definition. If the block returns nil or false no checkbox will be rendered.

  • # encoding: utf-8
    class HidingCheckboxesInActionColumnController < ApplicationController
      def index
        @tasks_grid = initialize_grid(Task,
          name: 'g',
          order: 'id'
        )
    
        if params[:g] && params[:g][:selected]
          @selected = params[:g][:selected]
        end
      end
    end
    
  • <%= grid(@tasks_grid) do |g|
    
      g.action_column html_check_box: false do |task|
        task.status.name != 'Assigned'
      end
    
    
      g.column name:  'ID', attribute: 'id', filter_type: :range
    
      g.column name:  'Title', attribute: 'title', negation: true
    
      g.column name:  'Archived', attribute: 'archived' do |rec|
        rec.archived? ? 'Yes' : 'No'
      end
    
    
      g.column name:  'Status', attribute: 'status_id', custom_filter: Status.to_dropdown  do |task|
        task.status.name if task.status
      end
    
      g.column name:  'Project Name', attribute: 'project_id', custom_filter: Project.to_dropdown do |task|
        task.project.name if task.project
      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
    
    end -%>
    
  • .well
      %h2= current_page_title
      %p
        You can hide a certain action checkbox if you add the usual block to
        %code g.action_column
        , just like with the
        %code g.column
        definition. If the block returns
        %code nil
        or
        %code false
        no checkbox will be rendered.
    
    = show_code
    
    = dump_filter_parameters_as_hidden_fields(@tasks_grid)
    = form_for '#', method:  :get do
    
      - if @selected
        .well
          Selected tasks:
          = @selected.to_sentence
    
      .row-fluid
        .col-md-12
          %p
            %button.btn.btn-default{'type' => 'submit'} Process tasks
    
          = render   'grid'
    
          %p
            %button.btn.btn-default{'type' => 'submit'} Process tasks
    

IDTitleArchivedStatusProject NameDue Date Added


1-20 / 500 Alle rijen tonen
325perferendis pariaturNoClosedSuper Game2016-01-062015-05-06 12:37:23
414quo architecto nonYesPostponedUltimate Website2016-01-072015-05-19 12:37:25
352autemNoPostponedSuper Game2016-01-082015-06-12 12:37:24
171qui est etNoAssignedUltimate Website2016-01-082015-04-09 12:37:21
253quosYesNewUltimate Website2016-01-082015-05-26 12:37:22
59alias liberoNoStartedUltimate Website2016-01-092015-03-23 12:37:19
206quia ipsum maximeNoVerifiedUltimate Website2016-01-092015-03-12 12:37:21
14repellat consequatur velitNoNewUltimate Website2016-01-102015-05-06 12:37:18
366debitis nihil quidemNoNewUltimate Website2016-01-102015-05-06 12:37:24
110hicNoStartedDivine Firmware2016-01-112015-05-11 12:37:20
454similique enim odioNoDuplicateDivine Firmware2016-01-112015-03-14 12:37:26
178molestias voluptas quiNoPostponedSuper Game2016-01-112015-04-14 12:37:21
194quoNoAssignedUltimate Website2016-01-122015-03-26 12:37:21
353rerum nam eligendiYesNewDivine Firmware2016-01-122015-04-08 12:37:24
82utNoCancelledDivine Firmware2016-01-122015-06-04 12:37:20
417provident eumNoVerifiedSuper Game2016-01-142015-05-26 12:37:25
424non autem solutaNoDuplicateDivine Firmware2016-01-142015-06-01 12:37:25
290voluptasNoDuplicateDivine Firmware2016-01-152015-06-02 12:37:23
211et dictaNoDuplicateUltimate Website2016-01-172015-04-22 12:37:22
222voluptasNoPostponedSuper Game2016-01-172015-06-04 12:37:22


Fork me on GitHub