gpt4 book ai didi

html - 如何在打印页面时修改表格中的列名?

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

我已经使用 RailsCasts 228 中描述的方法实现了一个可排序表.这些表正在工作并具有以下外观:

enter image description here

但是当我打印页面(Ctrl + P)时,打印结果如下:

enter image description here

显然它正在打印描述和链接。html.erb 中调用函数 sortable 的代码行如下所示:

 <th><%= sortable("name", t("map.contacts.list.name")) %></th>

还有排序函数:

    def sortable(column, title = nil)
title ||= column.titleize
direction = sort_direction == "asc" ? "desc" : "asc"
link_to title, {:filter => request.query_parameters['filter'], :sort => column, :direction =>direction}
end

当浏览器呈现时,表格的标题源看起来像这样:

<th><a href="/map/generate_list?direction=desc&amp;filter%5Bbirthday_end%5D=&amp;filter%5Bbirthday_init%5D=&amp;filter%5Bcreated_at_end%5D=&amp;filter%5Bcreated_at_init%5D=&amp;filter%5Bcreated_by%5D=&amp;filter%5Bcreated_by_id%5D=&amp;filter%5Bfilter_by_age%5D=0&amp;filter%5Bgender%5D=both&amp;filter%5Bmax_age%5D=65&amp;filter%5Bmin_age%5D=0&amp;filter%5Bstate%5D=&amp;filter%5Btag%5D=&amp;filter%5Btype%5D=both&amp;filter%5Buser_latitude%5D=-26.8257636&amp;filter%5Buser_longitude%5D=-49.2604414&amp;sort=name">Nome</a></th>

好吧,有没有人知道为什么会发生这种情况以及它是如何得到这个错误的?

最佳答案

我主要使用 chrome,我注意到它会在 URL 中抛出要打印的链接。可排序的表格通常在标题中有链接,并且路径似乎是由您友好的浏览器打印出来的。您可能会查看打印样式表:

.visable-print {
display: none;
}
@media print {
.hidden-print {
display: none;
}
.visable-print {
display: inline !important;
}
}

当媒体查询用于打印时,您本质上想要隐藏带有链接的表格部分,并将其替换为仅用于打印的名称。

关于html - 如何在打印页面时修改表格中的列名?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33679230/

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