我需要在 Spree 的管理后端的表中添加一列。每个都有一个数据挂钩<tr>
。
所以理论上我可以insert_top
在<td>
每一行上插入一个(并且在中插入一个<th>
和<thead>
在<col>
中插入一个<colgroup>
)。
这是最好的方法,还是有更好的方法?
使用一些带有新的 .deface DSL 的小文件,这很容易实现。例如使用 HAML(假设 Spree::Order 有一个自定义属性称为分发器)
标题:
/ insert_top "[data-hook='admin_orders_index_headers']"
%th
Distributor
行:
/ insert_top "[data-hook='admin_orders_index_rows']"
%td.align-center
= order.distributor.name
如果要更改列宽,通常只覆盖 colgroup 会更容易:
/ replace_contents "table#listing_orders colgroup"
%col{style: "width: 10%"}
...etc