如何使用 will_paginate 进行列排序,其中数据是记录数组,而不是模型
我有一个查询服务,我得到的数据经过过滤并创建一个记录数组。
除非我错过了什么,否则 ActiveResource::Base 不符合资格,因为对服务的访问不是通过休息,而且我无法使用交付的原始数据。
我正在表中显示数据并使用 will_paginate 对数据进行分页。但我目前还没有与 will_paginate 结婚。
我确实需要对列进行排序以及分页。
我找到了两个版本的ujs_sort_helper。
我试图理解: - http://javathehutt.blogspot.com/ 2009/06/mo-simple-sortable-tables-in-rails.html
Rails 3 中还做了什么?或者 ujs_sort_helper 软件包之一就是正确的方法。
就数据刷新而言,这是一个仪表板。多个数据源将处理不同的 DIV。
另外,我是一个 Rails 菜鸟。但不是编程菜鸟。
I have a service I query and I get data I filter through and create a an array of records.
Unless I missed something, ActiveResource::Base does not qualify since the access to the service is not via rest and I can't use the raw data as delivered.
I am displaying the data in a table and use will_paginate to page the data. But I am not currently married to will_paginate.
I do need to sort the columns as well as paginate.
I have found two version of ujs_sort_helper.
I am trying to understand:
- http://javathehutt.blogspot.com/2009/06/mo-simple-sortable-tables-in-rails.html
What have other done in rails 3? Or is one of the ujs_sort_helper packages just he correct way to go.
In term of data refresh, this is a dashbaord. Multiple data source will address the various DIVs.
Also, I am a Rails noob. But not a programming noob.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您愿意,您可以使用 meta_search 的 sort_link 。
我喜欢它,因为它还可以使用 meta_where 轻松进行过滤。
您还可以通过 ajax 通过将 data-remote 属性添加到“a.sort_link”来实现该行为(我已通过 javascript 完成了该操作)。
You could use meta_search's sort_link if you wish.
I like it because it also does filtering incredibly easy with meta_where.
You can also make the behavior through ajax by adding the data-remote attribute to 'a.sort_link' (i have done that through javascript).
我欢迎 ujs_sort_helper 的维护者发表评论。只是 Rails 3 版本代码中的一些错误。现在 ujs_sort_helper 对我来说有效。
我没有做的是在此包上创建另一个分支。我将文件通过电子邮件发送给作者。
排序顺序现在比较符号,而不是符号与字符串。
我们通过当前订单值设置图标。排序子句应该是相反的。因此,显示向下箭头以升序显示列表,但“url”设置为按降序重新显示表格。
我不知道 :q 符号的用途是什么。
I would welcome the maintainer of ujs_sort_helper to comment. Just a bug here and there in the rails 3 version of the code. Now ujs_sort_helper works, for me.
What I have not done is create ANOTHER branch on this package. I emailed the file to the author.
sort order now compares symbols, instead of symbol to string.
The icon us set via the current order value. The sort clause should be the opposite. So show down arrow for the list being displayed in ascending order, but the 'url' is set to redisplay the table in descending order.
I have no clue what the :q symbol is supposed to be used for.