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
    

ID TitleArchivedStatusProject NameDue DateAdded


61-80 / 500 show all
61quia architectoNoAssignedDivine Firmware2016-08-022015-05-15 12:37:19
62eum velit saepeNoAssignedDivine Firmware2016-10-182015-03-15 12:37:19
63accusamusNoNewSuper Game2016-09-172015-04-15 12:37:19
64reiciendisNoNewSuper Game2016-04-122015-03-30 12:37:19
65eosYesStartedSuper Game2016-07-312015-04-21 12:37:19
66vitae at autemNoPostponedSuper Game2016-06-162015-05-06 12:37:19
67officia quo maioresNoCancelledSuper Game2016-10-052015-06-15 12:37:19
68exercitationem delectusNoPostponedDivine Firmware2016-10-012015-05-12 12:37:19
69similique placeat ipsaNoDuplicateDivine Firmware2016-03-192015-05-08 12:37:19
70autemNoStartedUltimate Website2016-08-042015-03-25 12:37:19
71atNoResolvedSuper Game2016-07-132015-04-28 12:37:19
72illum explicabo modiNoVerifiedSuper Game2016-05-272015-06-16 12:37:19
73iure architectoNoPostponedUltimate Website2016-08-202015-04-05 12:37:19
74molestiaeNoPostponedUltimate Website2016-03-052015-05-22 12:37:19
75velit non magniNoDuplicateDivine Firmware2016-09-162015-05-07 12:37:19
76totamNoNewUltimate Website2016-09-062015-03-31 12:37:19
77sed quibusdam isteNoNewDivine Firmware2016-06-182015-06-03 12:37:19
78exercitationem sapienteNoClosedDivine Firmware2016-06-182015-04-07 12:37:19
79animiNoVerifiedSuper Game2016-05-062015-05-04 12:37:19
80corrupti officiaNoAssignedSuper Game2016-09-292015-03-12 12:37:19


Fork me on GitHub