gpt4 book ai didi

jquery - 如何在 Rails 中重新排序表格数据,以便最新数据显示在顶部?

转载 作者:数据小太阳 更新时间:2023-10-29 08:11:26 25 4
gpt4 key购买 nike

目前表的创建方式如下。目前,最近的事件出现在结果的第 3/4 页。

<div class="row">
<div class="col-md-12">
<% if @events.any? %>
<div class="panel panel-default">
<div class="panel-heading panel-heading-unstyled">
<h3 class="panel-title padding-left">Proshare Admin</h3>
</div>
<div class="panel-body">
<table class="table proshare-table">
<thead>
<tr>
<th>Activity</th>
<th>From</th>
<th>To</th>
<th>Date</th>
<th class="th-last">Time</th>
</tr>
</thead>
<tbody>
<%= render @events %>
</tbody>
</table>
<%= will_paginate @events %>
</div>
</div>
<% end %>
</div>
</div>

最佳答案

分配 @events 时,按 Controller 中最近发生的事件排序。

def index
@events = Event.order(created_at: :desc)
end

关于jquery - 如何在 Rails 中重新排序表格数据,以便最新数据显示在顶部?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36957893/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com