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


81-100 / 500 Alle rijen tonen
81ad quo dolorNoStartedDivine Firmware2016-05-182015-05-05 12:37:20
82utNoCancelledDivine Firmware2016-01-122015-06-04 12:37:20
83enimNoDuplicateDivine Firmware2016-10-142015-03-14 12:37:20
84doloreNoResolvedUltimate Website2016-05-282015-04-04 12:37:20
85voluptatibus inventoreYesClosedUltimate Website2016-06-032015-06-12 12:37:20
86adipisciNoStartedSuper Game2016-02-072015-04-08 12:37:20
87nostrumNoClosedDivine Firmware2016-03-312015-06-13 12:37:20
88culpaNoPostponedDivine Firmware2016-10-192015-05-25 12:37:20
89provident consequatur remNoResolvedSuper Game2016-08-202015-03-30 12:37:20
90commodi et quisNoCancelledDivine Firmware2016-05-302015-04-27 12:37:20
91quaeratNoAssignedDivine Firmware2016-06-172015-06-08 12:37:20
92est praesentiumNoClosedSuper Game2016-01-192015-06-08 12:37:20
93autNoCancelledSuper Game2016-09-202015-04-04 12:37:20
94officiisNoNewUltimate Website2016-02-012015-04-01 12:37:20
95quibusdam beatae adYesVerifiedDivine Firmware2016-03-062015-05-05 12:37:20
96impedit explicabo voluptatemNoVerifiedUltimate Website2016-10-252015-06-02 12:37:20
97voluptatem facilis etNoStartedDivine Firmware2016-05-262015-03-15 12:37:20
98aperiam rerumYesClosedSuper Game2016-07-192015-05-31 12:37:20
99solutaNoAssignedDivine Firmware2016-10-122015-03-25 12:37:20
100autem nonNoResolvedSuper Game2016-08-042015-05-02 12:37:20


Fork me on GitHub