Controls form

SmartListing includes controls form that allows for AJAX-enabled filtering of entries. You can add it in your view using
smart_listing_controls_for
helper. You also obviously need to handle controls form parameters in your controller.

defindexusers_scope=User.active# Apply the search control filter.# Note: `like` method here is not built-in Rails scope. You need to define it by yourself.users_scope=users_scope.like(params[:filter])ifparams[:filter]# Apply the credit card checkbox filterusers_scope=users_scope.with_credit_cardifparams[:with_credit_card]=="1"@users=smart_listing_create:users,users_scope,partial:"users/list",default_sort:{name:"asc"}end

Custom list

SmartListing can be used not only with tables. Just create custom view definitions in SmartListing partials and you can for example show a nice FAQ list with Bootstrap 3 components using only the usual
smart_listing_render
method in main view. You can also add controls form for simple searching.

More Customization

SmartListing 1.1.0 brings also some improvement in terms of customization. Apart from application-wide class and attribute customization (via initializer file) you can now define your named config profiles and use different config profile for every SmartListing in your app. This is particularly helpful when you are building Rails engine and don't want to interfere with main app configuration.

To start with config profiles, create an initializer and name your profile:

This will make all SmartListing helpers refer to your
:awesome_profile
in all rendered views.

One last thing is to make Javascript helpers using your profile too.
SmartListing.config.merge()
method does that by accepting JSON with config values. This JSON on the other hand can be obtained by using helper
SmartListing.config(:awesome_profile).to_json

The typical use case for this is to dump your config profile variables as body data attribute: