Sha256: eef30525240738604371820cdec68e3fa78d185ca124f60f750572760d8cc4d9

Contents?: true

Size: 1.49 KB

Versions: 106

Compression:

Stored size: 1.49 KB

Contents

# The LiveSearchGridPanel provides a search field in the toolbar of
# the GridPanel. 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.  NOTE: this is rewrite of the Netzke community
# pack component of the same name.  We should submit this to the
# community.
#
# Options:
# * +live_search_scope+ - The scope name for filtering the results by
#   the live search (default: :live_search)
#

class Marty::LiveSearchGridPanel < Marty::McflyGridPanel
  client_class do |c|
    c.listen_fn = l(<<-JS)
    function(obj, search_text) {
        var lg = this.ownerCt.ownerCt;
        lg.getStore().getProxy().extraParams.live_search = search_text;
        lg.getStore().load();
    }
    JS

    c.tbar = ['->', {
                name:  'live_search_text',
                xtype: 'textfield',
                enable_key_events: true,
                ref: '../live_search_field',
                empty_text: 'Search',
                listeners: {
                  change: {
                    fn: c.listen_fn,
                    buffer: 100,
                  }
                }
              }]
  end

  def get_records(params)
    search_scope = config[:live_search_scope] || :live_search
    model.send(search_scope, params && params[:live_search] || '').scoping do
      super
    end
  end
end

Version data entries

106 entries across 106 versions & 1 rubygems

Version Path
marty-2.4.7 app/components/marty/live_search_grid_panel.rb
marty-2.4.6 app/components/marty/live_search_grid_panel.rb
marty-2.4.5 app/components/marty/live_search_grid_panel.rb
marty-2.4.4 app/components/marty/live_search_grid_panel.rb
marty-2.4.3 app/components/marty/live_search_grid_panel.rb
marty-2.4.2 app/components/marty/live_search_grid_panel.rb
marty-2.4.1 app/components/marty/live_search_grid_panel.rb
marty-2.4.0 app/components/marty/live_search_grid_panel.rb
marty-2.3.15 app/components/marty/live_search_grid_panel.rb
marty-2.3.14 app/components/marty/live_search_grid_panel.rb
marty-2.3.13 app/components/marty/live_search_grid_panel.rb
marty-2.3.12 app/components/marty/live_search_grid_panel.rb
marty-2.3.11 app/components/marty/live_search_grid_panel.rb
marty-2.3.10 app/components/marty/live_search_grid_panel.rb
marty-2.3.9 app/components/marty/live_search_grid_panel.rb
marty-2.3.8 app/components/marty/live_search_grid_panel.rb
marty-2.3.7 app/components/marty/live_search_grid_panel.rb
marty-2.3.5 app/components/marty/live_search_grid_panel.rb
marty-2.3.4 app/components/marty/live_search_grid_panel.rb
marty-2.1.5 app/components/marty/live_search_grid_panel.rb