Skip to content

Commit

Permalink
added an integer filter to the example with detached filters
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuri Leikind committed Feb 18, 2011
1 parent 9e45269 commit 40f5777
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
14 changes: 9 additions & 5 deletions app/views/detached_filters/index.html.erb
@@ -1,22 +1,22 @@
<%= grid(@tasks_grid, :show_filters => :always) do |g|

g.column :column_name => 'ID', :attribute_name => 'id', :no_filter => true
g.column :column_name => 'ID', :attribute_name => 'id', :detach_with_id => :task_id

g.column :column_name => 'Title', :attribute_name => 'title', :detach_with_id => :title_filter do |task|
link_to('Edit', edit_task_path(task.title))
end

g.column :column_name => 'Priority', :attribute_name => 'priority_id',
g.column :column_name => 'Priority', :attribute_name => 'priority_id',
:custom_filter => Priority.to_dropdown, :detach_with_id => :priority_filter do |task|
task.priority.name if task.priority
end

g.column :column_name => 'Status', :attribute_name => 'status_id', :custom_filter => Status.to_dropdown,
g.column :column_name => 'Status', :attribute_name => 'status_id', :custom_filter => Status.to_dropdown,
:detach_with_id => :status_filter do |task|
task.status.name if task.status
end

g.column :column_name => 'Project Name', :attribute_name => 'project_id',
g.column :column_name => 'Project Name', :attribute_name => 'project_id',
:custom_filter => Project.to_dropdown, :detach_with_id => :project_filter do |task|
link_to_if(task.project, task.project.name, project_path(task.project) )
end
Expand All @@ -35,6 +35,10 @@
end -%>

<table class="form">
<tr>
<td>ID</td>
<td><%= grid_filter @tasks_grid, :task_id %></td>
</tr>
<tr>
<td>Title</td>
<td><%= grid_filter @tasks_grid, :title_filter %></td>
Expand Down Expand Up @@ -62,7 +66,7 @@ end -%>
<td><%= button_to_function "Reset", reset_grid_javascript(@tasks_grid) %></td>
<td><%= button_to_function "Submit", submit_grid_javascript(@tasks_grid) %></td>
</tr>

</table>

<%= grid(@tasks_grid) %>
2 changes: 1 addition & 1 deletion db/schema.rb
Expand Up @@ -9,7 +9,7 @@
#
# It's strongly recommended to check this file into your version control system.

ActiveRecord::Schema.define(:version => 20090907214632) do
ActiveRecord::Schema.define(:version => 20100117201812) do

create_table "companies", :force => true do |t|
t.string "name"
Expand Down

0 comments on commit 40f5777

Please sign in to comment.