<%= @title || "Listing posts" %>

Empty Collection

<%= magic_grid(@some_array, ["Name", "E-mail Address", "Website"], :searchable => true, :post_filter => Proc.new {|c| Rails.logger.debug "Final filter!"; c}) %>

External listener

<%= select nil, :user_id, options_from_collection_for_select(User.all, :id, :name, params[:user_id]), {:prompt => true}, :id => :user_id %> <%= magic_grid(@posts, [ :title, {:col => :body, :to_s => Proc.new {|r| r.body.truncate(30)} }, :published, :user, { :label => 'Actions', :to_s => Proc.new { |post| %> <%= link_to 'Show', post %> <%= link_to 'Edit', edit_post_path(post) %> <%= link_to 'Destroy', post, confirm: 'Are you sure?', method: :delete %> <% } } ], :searchable => [:body, 'users.name'], :live_search => 2000, :search_method => false, :min_search_length => 2, :per_page => 5, :listeners => { :user_id => :user_id }, :searcher_size => 42, :id => 1, :remote => true, ) %>

Basic grid with built-in search

<%= magic_grid(@posts, [ :title, {:col => :body, :to_s => Proc.new {|r| r.body.truncate(30)} }, :published, :user, { :label => 'Actions', :to_s => Proc.new { |post| %> <%= link_to 'Show', post %> <%= link_to 'Edit', edit_post_path(post) %> <%= link_to 'Destroy', post, confirm: 'Are you sure?', method: :delete %> <% } } ], :searchable => [:body, 'users.name'], :per_page => 5, :id => 2, :remote => true) %>

External search field

<%= search_field_tag :posts_search %> <%= magic_grid @posts, [:title, :body, :published, :user, 'Actions'], :searchable => [:body, 'users.name'], :searcher => :posts_search, :live_search => true, :search_method => false, :id => 3, :remote => true do |post| %> <%= post.title %> <%= post.body.truncate(30) %> <%= post.published %> <%= link_to post.user, post.user %> <%= link_to 'Show', post %> <%= link_to 'Edit', edit_post_path(post) %> <%= link_to 'Destroy', post, confirm: 'Are you sure?', method: :delete %> <% end %> <%= link_to 'New Post', new_post_path %>