【问题标题】:Sorting table with will_paginate on rails 3在rails 3上使用will_paginate排序表
【发布时间】:2011-07-25 00:23:26
【问题描述】:

我想知道如何使用 paging(will_paginate) 对表格列进行排序,我已经进行了分页,但我不知道如何对表格进行排序,即使它有分页,我的事情甚至需要分页,当你对你想要的列进行排序时,它会对你想要排序的那些对应的列进行排序,就像一个 ID 它应该从第 1 页升序或降序到其他页面直到最后,即使你在页面例如4,当我对 ID 进行排序时,例如从降序到升序(100 -> 1135),不仅在该页面中,而且它会对所有列出的数据进行排序......

我应该在控制器或助手以及我的表格中添加什么?

谢谢,希望有人回答,

index.html.erb

<table class="patchtable tablesorter"> <thead>
<th>ID</th>
<th>Summary</th>
<th>Module</th>
<th>Target</th>
<th>Category</th>
<th>Priority</th>
<th>Status</th>
<th>Assigned</th></tr>

<%= will_paginate @patches, :url => '/admin/patches', :align => "center", :params => {:controller => '/admin/patches', :action => nil, :order => @filter.filter_hash} %> <%= page_entries_info @patches, :entry_name => 'item' %>

我的控制器:

@patches = Admin::Patch.all(:conditions => filter_hash).paginate(:per_page => Admin::Patch.per_page, :page => params[:page])

我应该在这里做什么,添加或工作正常,请回复..

【问题讨论】:

    标签: ajax ruby-on-rails-3 sorting pagination


    【解决方案1】:

    查看此链接http://railscasts.com/episodes/228-sortable-table-columns。你会得到你想要的一切。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-10-03
      • 2012-03-10
      • 1970-01-01
      • 1970-01-01
      • 2023-03-22
      相关资源
      最近更新 更多