我正在尝试使用 custom_order 来呈现任意初始顺序。
# GET /sequences
def index
@sequences_grid = initialize_grid(Sequence,
enable_export_to_csv: false,
per_page: 10,
custom_order: {
'sequences.username' => "CASE WHEN username LIKE '#{current_user.username}' THEN 0 ELSE 1 END, username"
},
name: 'seq_g1')
end
这个想法是让当前用户的记录渗透到列表的顶部。
用户指南指出“键是数据库列的完全限定名称,并为在 ORDER BY 子句中使用的所需 SQL 块赋值”。
SQL 代码在数据库编辑器中运行时按预期工作,但网格未显示所需的顺序。
日志对任何 wice_grid 问题都保持沉默,并且报告的请求是:
10:10:35 web.1 | Sequence Load (0.3ms) SELECT distinct username FROM "sequences" ORDER BY username asc
10:10:35 web.1 | Sequence Load (0.3ms) SELECT distinct classtype FROM "sequences" ORDER BY classtype asc
10:10:35 web.1 | Sequence Load (0.2ms) SELECT distinct description FROM "sequences" ORDER BY description asc
10:10:35 web.1 | Sequence Load (0.2ms) SELECT distinct sequencenumber FROM "sequences" ORDER BY sequencenumber asc
10:10:35 web.1 | Sequence Load (0.2ms) SELECT distinct target FROM "sequences" ORDER BY target asc
10:10:35 web.1 | Sequence Load (0.2ms) SELECT distinct indicator FROM "sequences" ORDER BY indicator asc
我怀疑 SQL 代码可能会以某种方式被破坏,但在我深入挖掘之前,我认为有人可能遇到了类似的问题?
问候,汤姆。