Class: Netzke::Communitypack::LiveSearchGrid

Inherits:
Basepack::Grid
  • Object
show all
Defined in:
lib/netzke/communitypack/live_search_grid.rb

Overview

The LiveSearchGrid provides a search field in the toolbar of the Grid. While the content of the search field is changeing, the data in the grid gets reloaded and the filter string is given to a scope on the configured model. The scope name by default is :live_search but it can be reconfigured by the configuration option :live_search_scope.

Options:

  • live_search_scope - The scope name for filtering the results by the live search (default: :live_search)

Instance Method Summary (collapse)

Instance Method Details

- (Object) configure(c)



11
12
13
14
15
16
17
18
19
# File 'lib/netzke/communitypack/live_search_grid.rb', line 11

def configure(c)
  c.tbar = ['->', {
      :xtype => 'textfield',
      :enable_key_events => true,
      :name => 'live_search_field',
      :empty_text => 'Search'
    }]
  super
end

- (Object) get_data(*args)



49
50
51
52
53
54
55
# File 'lib/netzke/communitypack/live_search_grid.rb', line 49

def get_data(*args)
  params = args.first
  search_scope = config[:live_search_scope] || :live_search
  data_class.send(search_scope, params && params[:live_search] || '').scoping do
    super
  end
end